good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
Re: Regex replace in contextby jkahn (Friar) |
on Dec 11, 2002 at 18:39 UTC ( [id://219144]=note: print w/replies, xml ) | Need Help?? |
FWIW, it also means that $& does not include a.
I find the negative zero-width-lookbehind assertion rather handy (e.g. s/(?<!z)b/d/), which means, roughly, "substitute b for d whenever it's not preceded by z". This trick reminds me of the reason we have \b -- sometimes a boundary condition can be met by no character at all, e.g., we'd like to match on both "b" and "ab". In both cases, I've taken advantage of the not-modifying-$& effects in my code. I wish you could add the quantifiers, though, even though I can imagine just how complicated look-behinds with quantifiers might become... jyust my $0.02, --jeremy
In Section
Seekers of Perl Wisdom
|
|