in reply to Why this regexp doesn't match nested parens?

Using the \A anchor will make the regex fail as soon as it recurses since it will try to match the beginning of the string (hence only the first example string succeeding in your case). If you're matching nested parens then Regexp::Common::balanced can help you out e.g
use Regexp::Common; my @examples = qw/ (*********) (***(*)***) ((***)) (((***))) ((**)**(**)) (((()))) /; for( @examples ) { chomp; print "$_: "; print $& if $_ =~ $RE{balanced}{-parens=>'()'}; print "\n"; } __output__ (*********): (*********) (***(*)***): (***(*)***) ((***)): ((***)) (((***))): (((***))) ((**)**(**)): ((**)**(**)) (((()))): (((())))
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: Why this regexp doesn't match nested parens?
by ccn (Vicar) on Apr 26, 2004 at 16:44 UTC
    thanks, I mess that