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

Startseite
Nachricht löschen
Autor: ND
Datum:  
To: pcre-dev
Betreff: Re: [pcre-dev] Add ability to return last MARK with failed match
On Fri, 11 Nov 2011 20:09:49 +0400, Philip Hazel <ph10@???>
wrote:

> 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.


I suppose is not the Perl way. It seems that Perl keeps last MARK value
regardless starting point was advanced.

Perl code:
$_ = "abc";
if (/b(*:m)f|a(*:n)w/) { print "-YES-$REGMARK"; }
else { print "-NO-$REGERROR"; }

Result:
-NO-m

*MARK:m was keeped by Perl in $REGERROR and may be accessed after match
fails.