$string="I love chocolate."; $string =~ s/chocolate(?= ice)/vanilla/; print "$string\n"; $string="this is a test."; $string =~ s/this(?=is)/test/g; print "$string\n";