Re: [pcre-dev] several messages

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: ND
CC: Pcre-dev
Subject: Re: [pcre-dev] several messages
On Sun, 22 Jan 2012, ND wrote:

> Let whole string be 'abc' and we want to test it against pattern
> '(?!b)(?<=a)'. If we apply this pattern to whole string (without 'partial
> hard') then result will be 'no match'.
> Now let this string arrive to application by two chunks: 'a' and 'bc'.
> Applying first chunk with 'partial hard' option results 'match'. Thus in this
> case we finded that whole string 'abc' matches. This contradict with expected
> result.


I do understand what you want. The current behaviour does not give you
what you want. However, I do not want to change the current behaviour
(or at least not much) because that would be incompatible and probably
somebody would get caught out.

Therefore: to give you what you want we must invent some new option, or
perhaps make NOTEOL affect \Z and \z (a smaller incompatible change).

What you need is for pcre_exec to know *for sure* that it does not have
the end of the subject string. Currently, setting partial matching does
not give it that absolute assurance.

Even so, there is the problem of returning a zero-length partial match.
I do not like this because, for a non-anchored pattern, you can *always*
(well, almost always) find a zero-length partial match. Consider
something simple like /abcd/ matched partially against "xyz". If
zero-length partial matches are permitted, it would return a partial
match at the end of the string, instead of no match. Is that useful?
I have assumed that it is not useful.

Philip

--
Philip Hazel