http://www.perlmonks.org?node_id=574517

dfaure has asked for the wisdom of the Perl Monks concerning the following question:

Dears Monks,

Developping a custom formula interpreter, I'm using a recursive regexp inspirated from the one here to match inner-most bracketed blocks first. My problem comes at trying to deal with quoted strings containing bracketed text (which should obviously be considered as regular arguments):

my $textInner = '(outer(inner(most "this (shouldn\'t match)" inner)))'; my $innerRe; $innerRe = qr/ # \( # Start with '(', ( # Start capture (?>[^()]+) # Non-parenthesis | (?> "[^"]*")+ # !!! don't work... | (??{ $innerRe }) # Or a balanced () block ) # One time only, aka the inner one \) # Ending with ')' /x; # $textInner =~ /$innerRe/gs; print "inner: $1\n"; __END__ inner: shouldn't match

Any hints on this would be appreciated.

____
HTH, Dominique
My two favorites:
If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
Bien faire, et le faire savoir...