quick regex question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Keith Hughitt

    quick regex question

    Anyone know how to match something wrapped using perl-style regular
    expressions?

    e.g. given "function(input , input2, etc)"

    How can you match just the inputs? $re = "/function\([^\)]*\)/"; will
    match the entire string, but I'd prefer to just
    get back the inputs.

    Any advice would be greatly appreciated.

    Thanks!
    Keith
  • Serial # 19781010

    #2
    Re: quick regex question

    On Sat, 27 Sep 2008 05:11:08 -0700 (PDT), Keith Hughitt
    <keith.hughitt@ gmail.comwrote:
    >Anyone know how to match something wrapped using perl-style regular
    >expressions?
    >
    >e.g. given "function(input , input2, etc)"
    >
    >How can you match just the inputs? $re = "/function\([^\)]*\)/"; will
    >match the entire string, but I'd prefer to just
    >get back the inputs.
    >
    >Any advice would be greatly appreciated.
    >
    $test = "function(input , input2, etc)";

    if ( preg_match("/function\(([^\)]*)\)/", $test, $match) )
    {
    $inputs = preg_split("/[\,\s]+/", $match[1]);
    print_r($inputs );
    }


    Comment

    Working...