Re: [pcre-dev] Partial match at end of subject

Página Principal
Apagar esta mensagem
Autor: ND
Data:  
Para: Pcre-dev
Assunto: Re: [pcre-dev] Partial match at end of subject
On 2019-07-12 15:17, ph10 wrote:
> On Fri, 12 Jul 2019, ND via Pcre-dev wrote:
>> This is about my second example.
> > But it seems first example have another issue:
> >> >PCRE2 version 10.33 2019-04-16
> > >/(?<=(?=.(?<=x)))/
> > >ab\=ph
> > >Partial match: b
> >> Why it matched b?
>Again, it has inspected at least one character, and if you add "x" it
> matches.


But I not try to add x. I inspect lookbehind for x. Why it matches "abx"?


> > And there is another example with result that I don't understand:
> >> /\z/
> > ab\=ph
> > 0:
> >> Why it's result is not "no match"?
>It's a complete match, not a partial match. You've asked for a match at
> the end of the subject, and it has.
>


Doc say:

PCRE2_PARTIAL_HARD WITH pcre2_match()
If PCRE2_PARTIAL_HARD is set for pcre2_match(), PCRE2_ERROR_PARTIAL is
returned as soon as a partial match is found, without continuing to search
for possible complete matches. This option is "hard" because it prefers an
earlier partial match over a later complete match. For this reason, the
assumption is made that the end of the supplied subject string may not be
the true end of the available data, and so, if \z, \Z, \b, \B, or $ are
encountered at the end of the subject, the result is PCRE2_ERROR_PARTIAL,
provided that at least one character in the subject has been inspected.

So in PCRE2_PARTIAL_HARD mode \z can't be successfully matched. It's
always false.