If \b, a zero-width assertion, doesn't care whether it's placed before or after the word it's guarding (so to speak), why should (?= ) care that it is for lookahead only? What is it that makes (?<= ) necessary, and (?= ) unable to fill both niches?
You seem to be under the assumption that (?= ) and (?<= ) match the same thing. That isn't true, as the program below shows:
#!/usr/bin/perl use strict; use warnings; no warnings qw /syntax/; $_ = "---abc"; print "Lookahead matches\n" if /(?=abc)\w/; print "Lookbehind matches\n" if /(?<=abc)\w/; __END__ Lookahead matches
See, if (?= ) and (?<= ) are different, no construct could replace them both.
Abigail
In reply to Re: Why do zero width assertions care about lookahead/behind?
by Abigail-II
in thread Why do zero width assertions care about lookahead/behind?
by davido
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |