develooper Front page | perl.perl5.porters | Postings from February 2009

Re: regexp iteration limits

Thread Previous | Thread Next
February 12, 2009 00:21
Re: regexp iteration limits
Message ID:
David Nicol wrote:
>$ perl -lwe '$a="xyzt"x10000; utf8::upgrade($a);print $a =~
>/\A(?>(?>[a-z])*)*\z/ ? "ok" : "bug"'

The form you give here has very inefficient behaviour for a non-matching
string.  Also, if the inner expression is more complex (e.g., (?>X?[a-z])
it generates the "recursion limit" warning.  So it's better done as


I considered this class of workaround.  It works for non-backtracking
expressions, and effectively squares the iteration limit.  It's a great
practical improvement, but still most unsatisfying that it still has
a limit that is smaller than achivable address spaces.  One can apply
multiple layers of quantification to get a still higher iteration limit,
but then I don't know how many to do.

So, it's an option.  I'm happier using this as a local hack than as a
public solution.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About