in reply to How to substitute all the words before a certain word in the middle of a line?
my $triggerword = "nice"; my $replacement = "A "; while(<DATA>){ s/^.*?(?=$triggerword)/$replacement/o; print; } __DATA__ This is a nice weather. He is a nice guy. We have some nice food in our dinner.
|
|---|