Autor: Philip Hazel Data: Para: ND CC: Pcre-dev Assunto: Re: [pcre-dev] Why PARTIAL match happens?
On Sun, 17 May 2009, ND wrote:
> Good day!
>
> Subject string: --z
> Regexp: z(*F)
> Why PCRE_ERROR_PARTIAL, not PCRE_ERROR_NOMATCH happens?
Because it is a partial match. The match has succeeded as far as the end
of the subject string.
OK, I see that this is perhaps confusing. It works by setting the
"partial match" flag whenever the end of the subject string is reached,
before looking at what comes next. If this flag is set, "no match"
becomes "partial match". This is documented in the "pcrepartial" man
page, which says "the return code PCRE_ERROR_NOMATCH is converted into
PCRE_ERROR_PARTIAL if at any time during the matching process the last
part of the subject string matched part of the pattern".
It might seem more "natural" for it to fail in the case above. I did not
think about this case when I added the (*F) feature. However, it is
complicated and it may be best just to make the documentation more clear
about the current behaviour because there are also cases like z(?=X)
which would behave in the same way.