in reply to A demanding parser
Is there any way of avoiding the external module and catch an arbitrary number of nested parentheses with a "normal" Regex? I know that the Owl book says it can't be done, but I would like to put my mind at rest on this issue.
It depends on what you call a "normal" regex. If normal means without any perl specific things, it can not be done. But if you don't mind a perl specific regex, perlre has the solution:
The following pattern matches a parenthesized group:$re = qr{ \( (?: (?> [^()]+ ) # Non-parens without backtracking | (??{ $re }) # Group with matching parens )* \) }x;
2;0 juerd@ouranos:~$ perl -e'undef christmas'
Segmentation fault
2;139 juerd@ouranos:~$
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: A demanding parser
by TheDamian (Vicar) on Jan 25, 2002 at 17:12 UTC | |
by Juerd (Abbot) on Jan 25, 2002 at 20:34 UTC | |
by TheDamian (Vicar) on Jan 27, 2002 at 15:14 UTC | |
by gmax (Abbot) on Jan 31, 2002 at 06:59 UTC | |
Re: Re: A demanding parser
by gmax (Abbot) on Jan 26, 2002 at 18:56 UTC | |
Re^2: A demanding parser
by Aristotle (Chancellor) on Jan 25, 2002 at 17:07 UTC | |
by Juerd (Abbot) on Jan 25, 2002 at 20:31 UTC |
In Section
Meditations