PHP preg_match to get function-like string
- by pistacchio
Hi to all,
if I have a string like 'foo(bar)', with the following code i can almost parse it the way i want:
$results = array();
preg_match( "/\w*(?=(\(.*\))?)/", 'foo(bar)', &$results );
print_r($results);
/*
Array
(
[0] => foo
[1] => (bar)
)
*/
How can I modify the regex to have bar instead of (bar)? Thanks