[pcre-dev] Clearing documentation about infinite loops

Top Page

Reply to this message
Author: ND
Date:  
To: Pcre-dev
Subject: [pcre-dev] Clearing documentation about infinite loops

Good day!


Docs says:

It is possible to construct infinite loops by following a group that can
match no characters with a quantifier that has no upper limit, for example:
(a?)*
Earlier versions of Perl and PCRE1 used to give an error at compile time
for such patterns. However, because there are cases where this can be
useful, such patterns are now accepted, but if any repetition of the group
does in fact match no characters, the loop is forcibly broken.



Here is pcre2test listing:

PCRE2 version 10.33 2019-04-16
/(?:a|(?=b)|.)*\z/
abc
0: abc


May be docs need some clarification about what happened at that point.
After lookahead assertion (?=b) matches, loop is not broken. It seems a
backtracking occurs as if group was false.

And at first glance previous example is not well going together with this:

PCRE2 version 10.33 2019-04-16
/(?:a|(?=b)|.)*/
abc
0: a


First example matches "abc". But second - not.


Look at this issue please.