ysth has asked for the wisdom of the Perl Monks concerning the following question:
Given that, I'm expecting this:"(*MARK:*NAME*)" "(*:*NAME*)"
This zero-width pattern can be used to mark the point reached in a string when a certain part of the pattern has been successfully matched. This mark may be given a name. A later "(*SKIP)" pattern will then skip forward to that point if backtracked into on failure.
"aab" =~ /(*SKIP:go)(.)(?!\1(*MARK:go))/
to match the b. Instead, it matches the second a, just as it would if the skip and mark were omitted.
Perhaps iterating over the string to begin the match doesn't count as "backtracked into"? But then I'd expect
to capture the b, yet it again captures the second a."aab"=~/^.*?(*SKIP:go)(.)(?!\1(*MARK:go))/
Perhaps subpatterns such as (?!...) don't share marks with the main pattern? The slightly more verbose pcre doc seems to say that. But then this should work:
and it doesn't."aab"=~/(*SKIP:go)(.)(?(?=\1)\1(*MARK:go)(*FAIL)|)/
I suspect I'm just misunderstanding something fundamental here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: understanding (*SKIP:...)
by ikegami (Patriarch) on Jun 11, 2025 at 22:05 UTC | |
by ysth (Canon) on Jun 12, 2025 at 02:06 UTC | |
by ysth (Canon) on Jun 11, 2025 at 23:09 UTC | |
by ikegami (Patriarch) on Jun 12, 2025 at 00:19 UTC | |
|
Re: understanding (*SKIP:...)
by ysth (Canon) on Jun 11, 2025 at 21:53 UTC |