varian has asked for the wisdom of the Perl Monks concerning the following question:
Clearly this could be solved by using loops, functions etc yet surely there must be a way to achieve this with a single regex?E.g. $source = '(aaa) (bbb (ccc( ddd) eee) (fff)' using: (@destination) = ($source =~ / ... / ); would need to result in: $destination[0] = 'aaa' $destination[1] = 'bbb (ccc( ddd) eee' $destination[2] = 'fff'
I played a bit with forward/backward anchoring etc yet the possible (non-balanced) nesting of parenthesis makes it an intriging challenge.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex to parse (nested) parenthesis delimited string?
by davorg (Chancellor) on Feb 06, 2007 at 16:44 UTC | |
|
Re: regex to parse (nested) parenthesis delimited string?
by imp (Priest) on Feb 06, 2007 at 16:45 UTC | |
by varian (Chaplain) on Feb 06, 2007 at 17:02 UTC | |
by imp (Priest) on Feb 06, 2007 at 17:05 UTC | |
by polettix (Vicar) on Feb 06, 2007 at 18:27 UTC | |
|
Re: regex to parse (nested) parenthesis delimited string?
by kyle (Abbot) on Feb 06, 2007 at 16:45 UTC | |
|
Re: regex to parse (nested) parenthesis delimited string?
by fenLisesi (Priest) on Feb 06, 2007 at 18:11 UTC | |
by varian (Chaplain) on Feb 07, 2007 at 08:25 UTC |