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


in reply to How do i find $a and replace it with $b when it's preceded by $c?

A postivive look behind clause in the regular expression will do what you want.
my($a, $b, $c, $d) = qw{foo bar moo moofooyou); $d =~ s/(?<=$c)$a/$b/g;
produces moobaryou in $d
  • Comment on Re: How do i find $a and replace it with $b when it's preceded by $c?
  • Download Code