Mark-Jason Dominus wrote:
:This is not exactly the same, but I tried a direct translation:
:
: $re = qr{ \( (??{$re}) \)
: | (??{$re}) (??{$re})
: | (?> [^()]+)
: }x;
:
:and it looks worse and dumps core.
That's because the first non-paren forces it to recurse into the
second branch until you hit REG_INFTY or overflow the stack. Swap
second and third branches and you have a better chance:
$re = qr{
\( (??{$re}) \)
|
(?> [^()]+)
|
(??{$re}) (??{$re})
}x;
(I haven't checked that there aren't other problems with it, though.)
Hugo
- Re: XML/HTML-specific ?< and ... Randal L. Schwartz
- Re: XML/HTML-specific ?< and ... Mark-Jason Dominus
- Re: XML/HTML-specific ?< and ... Jarkko Hietaniemi
- Re: XML/HTML-specific ?< and ... Randal L. Schwartz
- Re: XML/HTML-specific ?< and ... Bart Lateur
- Re: XML/HTML-specific ?< and ... David L. Nicol
- Re: XML/HTML-specific ?< and ... Richard Proctor
- Re: XML/HTML-specific ?< and ... Jonathan Scott Duff
- Re: XML/HTML-specific ?< and ... Michael Maraist
- Re: XML/HTML-specific ?< and ... Mark-Jason Dominus
- Re: XML/HTML-specific ?< and ... Hugo
- Re: XML/HTML-specific ?< and ... Mark-Jason Dominus
- Re: XML/HTML-specific ?< and ... Hugo
- Re: XML/HTML-specific ?< and ... Mark-Jason Dominus
- Re: XML/HTML-specific ?< and ... David Corbin
- Re: RFC 145 (alternate approach) Jonathan Scott Duff
