tags:

views:

27

answers:

1

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

+4  A: 
'/\w*(?=(?:\((.*)\))?)/'
S.Mark