Correct me if I'm wrong, but doesn't the \K special escape emulate only the positive look-behind assertion? This is certainly suggested by perlre, in which the use of \K for variable-length look-behind is discussed only in the context of the (?<=pattern) assertion.
Update: However, the (*SKIP)(*FAIL) pair of Special Backtracking Control Verbs (5.10+) can be pressed into service for negative look-behind:
>perl -wMstrict -le "my $s = 'aaxbbbxccccxddxex'; ;; printf qq{'$_' } for $s =~ m{ [a-e]+ x }xmsg; print ''; ;; printf qq{'$_' } for $s =~ m{ [bd]+ (*SKIP)(*FAIL) | [a-e]+ x }xmsg; print ''; ;; printf qq{'$_' } for $s =~ m{ (?: [bd]+ (*SKIP)(*FAIL))? [a-e]+ x }xmsg; print ''; " 'aax' 'bbbx' 'ccccx' 'ddx' 'ex' 'aax' 'ccccx' 'ex' 'aax' 'ccccx' 'ex'
In reply to Re^2: Why is variable length lookahead implemented while lookbehind is not?
by AnomalousMonk
in thread Why is variable length lookahead implemented while lookbehind is not?
by Kc12349
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |