in reply to Interesting behavior of regular expression engine
G'day lightoverhead,
I ran that code and got the same result as you:
$ perl -Mstrict -Mwarnings -E ' "abcdef" =~ / .+ (?{say "Matched so far: $&"}) bcdef $/x; ' Matched so far: a
I then stepped through the code using Regexp::Debugger:
$ perl -Mstrict -Mwarnings -E ' use Regexp::Debugger; "abcdef" =~ / .+ (?{say "Matched so far: $&"}) bcdef $/x; '
This showed each of the six "Matched so far: ..." lines in the same order as you have them. It also showed backtracking behaviour as I, and presumably you, would expect.
The problem seems to lie with just the output; however, I don't know what that problem is.
-- Ken
|
|---|