Re: [pcre-dev] Unexpected result when zero-length global mat…

Pàgina inicial
Delete this message
Autor: ND
Data:  
A: Pcre-dev
Assumpte: Re: [pcre-dev] Unexpected result when zero-length global matching and pattern contains \G
On 2018-06-30 16:51, ph10 wrote:

>Note that this effect is in pcre2test, not in the basic library. /g is
> implemented entirely in pcre2test, so the basic library does not know it
> is handling a repeat match.
>


I'm surprised: is there another algorithm of working /g in pcretest in
comparing with PCRE2_SUBSTITUTE_GLOBAL in pcre2_substitute()?
I was sure that it is the same.
PCRE2_SUBSTITUTE_GLOBAL is ve-e-ery widely used with pcre2_substitute().
And pcre2_substitute, not pcretest is what I worry about foremost.


>This doesn't work. I tried it, with some debugging to show the values.
> It worked in the simple test case, but in the main tests this test and
> some others failed:
>
> /^/gm
>    a\nb\nc\n
>  0:~~start=0 end=0 offset=0
>  0:~~start=2 end=2 offset=1
> ** PCRE2 error: global repeat returned the same string as previous
> ** Global loop abandoned


I wonder that repeat return of the same match string as previous but at
another point in the subject is interpreted as error. Why? I think it
shouldn't.