The first one almost does the job, but it's simpler just to discard every single character before the nice IMHO...
my $sentence = "This is a nice weather. He is a nice guy.
We have some nice food in our dinner.";
$sentence =~ s:.*(\bnice\b.*?\.):A $1:g;
print "$sentence\n";
In reply to Re: How to substitute all the words before a certain word in the middle of a line?
by Anonymous Monk
in thread How to substitute all the words before a certain word in the middle of a line?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |