Re: [pcre-dev] (*SKIP:NAME) when (*MARK:NAME) is in assertio…

Páxina inicial
Borrar esta mensaxe
Autor: ph10
Data:  
Para: ND
CC: Pcre-dev
Asunto: Re: [pcre-dev] (*SKIP:NAME) when (*MARK:NAME) is in assertion
On Wed, 11 Jul 2018, ND via Pcre-dev wrote:

> I seen this docs before.
> But in example verb not appears inside assertion. It appears after it.


The (*MARK) is inside the assertion. That is what matters. I have
updated the documentation to say this:

The search for a (*MARK) name uses the normal backtracking mechanism,
which means that it does not see (*MARK) settings that are inside
atomic groups or assertions, because they are never re-entered by
backtracking. Compare the following pcre2test examples:

      re> /a(?>(*MARK:X))(*SKIP:X)(*F)|(.)/                                  
    data: abc                                                                 
     0: a                                                                       
     1: a                                                                       
    data:                                                                    
      re> /a(?:(*MARK:X))(*SKIP:X)(*F)|(.)/                                      
    data: abc                                                                    
     0: b                                                                      
     1: b                                                                     


In the first example, the (*MARK) setting is in an atomic group, so it
is not seen when (*SKIP:X) triggers, causing the (*SKIP) to be
ignored. This allows the second branch of the pattern to be tried at
the first character position. In the second example, the (*MARK)
setting is not in an atomic group. This allows (*SKIP:X) to
immediately cause a new matching attempt to start at the second
character. This time, the (*MARK) is never seen because "a" does not
match "b", so the matcher immediately jumps to the second branch of
the pattern.

This is exactly the same behaviour as Perl.

Philip

--
Philip Hazel