in reply to Why do zero width assertions care about lookahead/behind?
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Why do zero width assertions care about lookahead/behind?
by Roger (Parson) on Oct 09, 2003 at 01:51 UTC | |
by Abigail-II (Bishop) on Oct 09, 2003 at 08:46 UTC |