http://www.perlmonks.org?node_id=3496


in reply to How do I find $a only where it's not followed by $b and then replace it with $c?

Use Perl's cool "zero-width negative lookahead assertion".

s/$a(?!$b)/$c/;