Re: [pcre-dev] several messages

Top Page
Delete this message
Author: ND
Date:  
To: Pcre-dev
Subject: Re: [pcre-dev] several messages
On 2019-06-22 08:51, ph10 wrote:

> There must be plenty of examples where removing \z changes what is
> matched. How about /[ab]*\z/ matched against "aaaxxxbbb"?


I believed it was obviously that we told about matching from one position
of subject. Sorry that I don't say it explicitly.
In your example [ab]*\z is matched from 6 position of subject while [ab]*
matched from 0 position. There is no any logical contradiction in this
example.


> I suppose an alternative choice for dealing with matching an empty
> string would be to move on to the next alternative branch in the group
> (that is, ".") when there is another branch to try, but that is not what
> Perl chose to do.


I agree with you. If successful iteration which have zero length occurs
then engine can count it but backtrack as if iteration was not successful.
In this situation logical contradiction don't occurs. And there will be no
really incredible matches such as:

/\A(?:a|(?=b)|.){50}\z/
abc
0: abc

when engine in a strange way decides that it was exactly 50 repetitions.


> I'm afraid you will just have to live with this.


Perl-compatibility is important. So, indeed. If there is no one who can
discuss this issue with Perl-authors or to examine the issue of breaking
some PCRE-compatibility to achieve more logic.