Re: [pcre-dev] Quantifying backtracking verbs

Αρχική Σελίδα
Delete this message
Συντάκτης: ND
Ημερομηνία:  
Προς: Pcre-dev@exim.org
Αντικείμενο: Re: [pcre-dev] Quantifying backtracking verbs

> Repetition is allowed for groups such as (?:...) but not for individual
> backtracking verbs


It seems Perl does not rise error with "(*ACCEPT)??". And generates
expected code.
Is there weighty reason to be not compatible with Perl in this situation?


> (for which it is meaningless).


It's not true for (*ACCEPT).
Construct "(*ACCEPT)??" is like a negated (*COMMIT) pattern:
(*COMMIT) immediately fail a whole match when backtrack to it occurs
(*ACCEPT)?? immediately match when backtrack to it occurs

Consider a pattern:

(a(?:(*ACCEPT))??b)c

Lets we want to match "abc" and capture "ab". If "abc" don't match we want
to match "a" and capture it.
What another PCRE pattern allows doing this with same effectiveness (a,b,c
can be a large and complex subpatterns)?

So, this construct is not meaningless. Moreover, I can't find another
PCRE-pattern that can do the same without sacrifice of effectiveness.