in reply to Re: getting a return code from a looping regular expression
in thread getting a return code from a looping regular expression
Just a few minor modifications.@foo = ('a(b(c)d(e(f)g)h)i(j(k)l(m)n)o', 'a(b(c)d(e(f)g)h)i(j(k)l(m)n)o)'); for (@foo) { print "\'$_\' has "; while ( s/\([^()]*\)// ){} print "un" if /[()]/; print "balanced parentheses\n"; }
While you can use an algorithm like this to find if a string has matches parens, you can't write a single regexp that does it. Check out this node for a bit of an explination for this.
/\/\averick
|
|---|