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
In reply to Re: zero-width assertions for extended regular expressions
by AnomalousMonk
in thread zero-width assertions for extended regular expressions
by johnrcomeau
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |