Re: [pcre-dev] Quantifying backtracking verbs

Pàgina inicial
Delete this message
Autor: ND
Data:  
A: Pcre-dev
Assumpte: Re: [pcre-dev] Quantifying backtracking verbs
On 2019-06-20 15:53, ph10 wrote:
>I have updated the doc to use your example, but it can be done easily
> with other PCRE2 facilities:
> (?|(ab)c|(a))
> does the same thing. If "a" is complex, and you do not want to write it
> out twice, you could DEFINE it and use a subroutine call.
>


I don't say that it can't be done at all. I say that it can't be done with
same effectiveness (performance).
In your example "a" trying to match twice if "abc" is not match. With
(*ACCEPT)?? - only once.
You can add performance:


(?|((a)b)c|(\2))

But there is also less performance then with (a(*ACCEPT)??b)c. And much
more unreadable. And have excess capture.