Re: [pcre-dev] Inner (*MARK) don't keep its value outside th…

Page principale
Supprimer ce message
Auteur: Philip Hazel
Date:  
À: ND
CC: Pcre-dev
Sujet: Re: [pcre-dev] Inner (*MARK) don't keep its value outside the assertion
On Thu, 7 Apr 2011, ND wrote:

> Here is pcretest.exe listing:
>
> PCRE version 8.11 2010-12-10
> /(?=a(*:M))/K
> a
> 0:
>
> The marked value is not displayed in output. Why? I think it is practically
> useful to keep it's value outside the assertion.


This is a documented effect. In the pcrepattern documentation it says:

If any of these [backtracking control] verbs are used in an assertion
or subroutine subpattern (including recursive subpatterns), their
effect is confined to that subpattern; it does not extend to the
surrounding pattern. Note that such subpatterns are processed as
anchored at the point where they are tested.

The answer to your why? question is that because that is what naturally
happens in the code. However, I have just done a test with Perl, and I
see that it *does* record the mark for your example. So, when I get
round to it, I will look at the PCRE code to see if it is
straightforward to make it behave like Perl.

Philip

--
Philip Hazel