Re: [pcre-dev] Add ability to return last MARK with failed m…

Pàgina inicial
Delete this message
Autor: Philip Hazel
Data:  
A: ND
CC: Pcre-dev@exim.org
Assumpte: Re: [pcre-dev] Add ability to return last MARK with failed match
On Fri, 11 Nov 2011, ND wrote:

> Perl regexp documentation says:
>
> When a match has failed, and unless another verb has been involved in failing
> the match and has provided its own name to use, the $REGERROR variable will be
> set to the name of the most recently executed (*MARK:NAME).
>
> How you think about adding this ability to PCRE. May be the last MARK value
> may be returned by the same variable that in match case.


PCRE should already do this. This is from the test 2 output:

/^(A(*THEN:A)B|C(*THEN:B)D)/K
    CB    
No match, mark = B


If you have a case where it does not return a mark, it is a bug. Note,
however, that the documentation (pcrepattern) says this:

A name may also be returned after a failed match if the final path
through the pattern involves (*MARK). However, unless (*MARK) used in
conjunction with (*COMMIT), this is unlikely to happen for an
unanchored pattern because, as the starting point for matching is
advanced, the final check is often with an empty string, causing a
failure before (*MARK) is reached.

Philip

--
Philip Hazel