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

Kezdőlap
Üzenet törlése
Szerző: Philip Hazel
Dátum:  
Címzett: Herczeg Zoltán
CC: Pcre-dev
Tárgy: 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