in reply to zero-width assertions for extended regular expressions
Another way to think of it is that (zero-width) look-around assertions act from positions between characters, so in the string
5 4 W
^^
||
(?=4) looks forward from here|
|
at the character (W) here
So is W the same as 4? It is not. (Actually, the regex checks every possible position since it is not constrained to do otherwise, but even so, W is never 4.) And for (?=\d) likewise.
Update: Also consider:
c:\@Work\Perl\monks>perl -wMstrict -le "my $s = '54W'; ;; print 'match' if $s =~ m{ (?=4) . W }xms; " match
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: zero-width assertions for extended regular expressions (rxrx)
by Anonymous Monk on May 27, 2014 at 07:41 UTC |