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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A regexp to parse nested brackets containing strings
by davido (Cardinal) on Sep 23, 2006 at 15:50 UTC | |
|
Re: A regexp to parse nested brackets containing strings
by ikegami (Patriarch) on Sep 23, 2006 at 16:21 UTC | |
|
Re: A regexp to parse nested brackets containing strings
by rodion (Chaplain) on Sep 23, 2006 at 20:04 UTC | |
by ikegami (Patriarch) on Sep 23, 2006 at 21:35 UTC | |
by rodion (Chaplain) on Sep 24, 2006 at 08:27 UTC | |
by ikegami (Patriarch) on Sep 24, 2006 at 12:25 UTC | |
|
Re: A regexp to parse nested brackets containing strings
by Anonymous Monk on Sep 26, 2006 at 08:45 UTC | |
|
Re: A regexp to parse nested brackets containing strings
by Anonymous Monk on Sep 25, 2006 at 12:06 UTC |