Re: [pcre-dev] Assertions with quantifier behaviour is Perl …

Top Page
Delete this message
Author: ND
Date:  
To: Pcre-dev
Subject: Re: [pcre-dev] Assertions with quantifier behaviour is Perl incompatible
On 2011-05-02 13:13, Herczeg Zoltán wrote:

> You get the same result if you simply drop the quantifier.

No. Try Perl example
(?=a(b))?.*d\1?
against subject 'axbdb' with '?' after assertion and without it.
Results are different.

> Anyway, if you really need the quantifier, just put a non-capturing
> bracket around it.

Thanx. But the the aim of my post is not to get help about converting such
expressions to non erroneous variation in PCRE.
There are many other cases when converting may be done. But they don't
cause banning of other legal Perl constructions.
For example Perl expression 'a{2}' may be rewritten as 'aa'. But this is
not mean that construct '{2}' must be disallowed in PCRE as erroneous.

If it seems to be unuseful to repeat assertions more than one time than
PCRE can optimize such quantifiers at compile time to run an assertion
only once.
The ability to repeat an assertion 0 or 1 times is useful (example above).
I don't see a need to break compatibility with Perl in such cases.

Best regards.