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

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: Herczeg Zoltán
CC: Pcre-dev
Subject: Re: [pcre-dev] Assertions with quantifier behaviour is Perl incompatible
On Mon, 2 May 2011, Herczeg Zoltán wrote:

> assertion which does not needs to be true, some kind of logical
> contradiction :) Funny construct.


Indeed. It seems totally weird. Looks like the example given, that is,
(?=a(b))?.*d\1? is using the assertion to set capturing brackets for use
later on (but only optionally).

Note that one of the other differences between PCRE and Perl is the
treatment of capturing brackets in assertions. However, PCRE does set
them for positive assertions that succeed.

Another possible way of rewriting this pattern is something like this:

(?:a(b)|).*d\1?

OK, I know you are interested in maintaining compatibility, not
rewriting. However, there *are* differences between PCRE and Perl - that
is why the "pcrecompat" man page exists. There will never be complete
compatibility, and anybody converting complicated Perl patterns to PCRE
should expect the occasional difference. Sorry, but that's the way it
is.

Philip

--
Philip Hazel