That sets string to "123456abc789". (?=...) is a positive look-ahead, (?!=...) is a negative look-ahead. (?<=...) is a positive look-behind, (?<!...) is a negative look-behind.$string = "123456123789"; $a = 123; $b = "abc"; $c = 456; $string =~ s/$a(?!=$c)/$b/;
In reply to Re: Substitute $a with $b only when a is not followed by $c
by japhy
in thread Substitute $a with $b only when a is not followed by $c
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |