By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,746 Members | 1,928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,746 IT Pros & Developers. It's quick & easy.

quick regex question

P: n/a
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
Sep 27 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Sat, 27 Sep 2008 05:11:08 -0700 (PDT), Keith Hughitt
<ke***********@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);
}
Sep 28 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.