Re: [pcre-dev] Max lookbehind calculation

Góra strony
Delete this message
Autor: ph10
Data:  
Dla: ND
CC: Pcre-dev
Temat: Re: [pcre-dev] Max lookbehind calculation
On Mon, 17 Jun 2019, ND via Pcre-dev wrote:

> PCRE2 version 10.33 2019-04-16
> /(?<=.{2}(?<=.{6}))/info
> Capture group count = 0
> Max lookbehind = 6
> May match empty string
> Subject length lower bound = 0
> abc\=ph
> No match
>
>
> Expected maxlookbehind=4, not 6.


Why do you expect 4? The matcher goes back 2, then matches two
characters, so it is back at the start. Then it goes back 6.

PCRE2 version 10.34-RC1 2019-04-22
re> /(?<=.{2}(?<=.{6}))/

------------------------------------------------------------------
  0  29 Bra
  3  23 AssertB
  6   2 Reverse
  9     Any{2}
 13  10 AssertB
 16   6 Reverse
 19     Any{6}
 23  10 Ket
 26  23 Ket
 29  29 Ket
 32     End
------------------------------------------------------------------


Consider also:

PCRE2 version 10.34-RC1 2019-04-22
/(?<=a{2}(?<=[ab]{6}))(.*)/
      bbbbaaXXX
 0: XXX
 1: XXX
      cbbbaaXXX
No match


The successful match looked back 6 characters before XXX.                   


Philip

--
Philip Hazel