Autor: ph10 Fecha: A: ND Cc: Pcre-dev Asunto: Re: [pcre-dev] Partial match at end of subject
On Fri, 12 Jul 2019, ND via Pcre-dev wrote:
> > > > >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" itmatches.
>
> But I not try to add x. I inspect lookbehind for x. Why it matches "abx"?
There is a PCRE2 bug, even without \=ph so I will have to fix that and
then I will check out the partial match.
PCRE2 version 10.34-RC1 2019-04-22
/(?<=(?=.(?<=x)))/aftertext
abx
0:
0+ bx
Perl v5.30.0
/(?<=(?=.(?<=x)))/aftertext
abx
0:
0+ x
> > > 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 atthe
> >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.
In this case PCRE2 finds a *complete* match before it finds a partial
match. The pattern says "assert we are at the end of the subject"; that
is true. Then it says "end of pattern" - so it returns a complete match.
It never gets the chance to consider a partial match.
The matcher only considers a partial match if it is at the end of the
subject and *not* at the end of the pattern and the next pattern item
requires a character to test.