in reply to Regex replace in context
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex replace in context
by John M. Dlugosz (Monsignor) on Dec 11, 2002 at 21:32 UTC |