in reply to How to substitute all the words before a certain word in the middle of a line?

This would be a solution, keeping in mind that we assume all '.' characters terminate a line.

$line="This is a nice weather. He is a nice guy. We have some nice food in our dinner.";

foreach (split /\./,$line) {
s/^.*(nice.*)/$1/;
$result.="A $_.";
}
print $result;

  • Comment on RE: How to substitute all the words before a certain word in the middle of a line?

Replies are listed 'Best First'.
RE: RE: How to substitute all the words before a certain word in the middle of a line?
by vkonovalov (Monk) on Jul 12, 2000 at 14:31 UTC
    I doubt that this code will work properly... I think this algorithm is far away of originally desired one.