tshabet has asked for the wisdom of the Perl Monks concerning the following question:
sequence for a matching regexp to match a string with balanced braces using this recursion regexp:(??{CODE})
It turned out the problem I had was that I was using an old version of perl that didn't support the delayed interpolation sequence. So no problem, I upgraded and all is fine and dandy etc. But here's my question: Lets say that the sequence didn't exist, or that I'm using perl circa Billy Idol or something. I know that without this newer form of perl recursion a standard regex wouldn't be able to make this type of nested brace match(or so I've been told by coders more knowledgable than I). So my thinking went like this: When I finally decided I needed some monk advice for my previous problem, I had already invested a lot of time and energy into what I had hoped would be a handy and useful program. How could I have at least come close to the function of the newer sequence without using it? By this I mean, if I was unable to use the delayed interpolation sequence and had to replace the regex with some "old fashioned" code, what would my options be? I was very worried about this problem until my salvation yesterday, now its only a "what if" question for people who are in the know. Don't worry, everything is working fine :-) I was just wondering what, say, the author of the recdescent module did to achieve similar effect back in the dark ages.$np = qr{ \{ (?: (?> [^{}]+ ) | (??{ $np }) )* \} }x;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Balancing braces without (??{})
by John M. Dlugosz (Monsignor) on Jul 28, 2001 at 00:30 UTC | |
by tshabet (Beadle) on Jul 28, 2001 at 01:04 UTC | |
by John M. Dlugosz (Monsignor) on Jul 28, 2001 at 01:47 UTC | |
by John M. Dlugosz (Monsignor) on Jul 29, 2001 at 00:18 UTC | |
|
(tye)Re: Balancing braces without (??{})
by tye (Sage) on Jul 28, 2001 at 01:55 UTC | |
|
Re: Balancing braces without (??{})
by I0 (Priest) on Jul 28, 2001 at 06:14 UTC |