Re: [pcre-dev] (*SKIP) action

Top Page
Delete this message
Author: Philip Hazel
Date:  
To: ND
CC: Pcre-dev
Subject: Re: [pcre-dev] (*SKIP) action
On Sat, 12 Sep 2009, ND wrote:

> PCRE documentation says about (*SKIP):
>
> This verb is like (*PRUNE), except that if the pattern is unanchored, the
> "bumpalong" advance is not to the next character, but to the position in
> the subject where (*SKIP) was encountered.
>
> Subject string: '0123456789'
> Pattern: (?=....(*SKIP))1
>
> I waits no matches, but there is a match in position 1. Why (*SKIP) dont
> force the jump to bumpalong='4' after first submatch fails?


This is a documentation omission.

The Perl documentation does not say anything about what happens if *SKIP
is used in an assertion, but I tested this pattern with Perl 5, and it
behaves the same way as PCRE.

What happens in PCRE (and I deduce must be the same in Perl) is that an
assertion is treated like a mini-pattern of its own. So when it tests
the assertion, it matches the pattern (?....(*SKIP)) against the
string, and of course that match always succeeds. So the assertion is
true and the match happens.

I will update the PCRE documentation to explain this.

Philip

--
Philip Hazel