Autor: ND Data: Dla: Pcre-dev Temat: Re: [pcre-dev] Partial match at end of subject
On 2019-07-18 16:48, ph10 wrote: > On Wed, 17 Jul 2019, ND via Pcre-dev wrote:
>Let us ignore for the moment whether there should be a new option or
> not, and try to figure out what new logic might be needed. I am going to
> experiment with the suggestion I made earlier:
> If a hard partial match is possible, return PCRE2_PARTIAL if EITHER
> at least one character has been inspected, OR the pattern contains a
> lookbehind of length 1 or more. If neither of these conditions is
> true, return "no match".
>
It's reasonable suggestion.
Alternative suggestion may be:
Returning "no match" only for "global no match", when current segment and
all next segments can't match.
If a hard partial match is possible then always return "partial match"
regardless of presence of inspected characters and lookbehinds.
In ovector[0] after "partial match" return start_match_pos -
max_lookbehind (or 0 if it is negative). Main application must keep a tail
of subject from position at ovector[0] (it may be 0 length) and
concatenates it with next segment.
Advantages:
1. It will be unnecessary to main app doing calculations with
PCRE2_INFO_MAXLOOKBEHIND after matching every segment - this will become
PCRE internal work.
2. PCRE2_INFO_MAXLOOKBEHIND option of pcre2_pattern_info() can be
deprecated.
3. Ambiguity about global and local meaning of "no match" will be gone.