Include word boundaries in the patterns.
my @phrases = ( 'pail of water', 'pale horse' ); my $phrases_re = join '|', map { "\\b$_\\b" } map { quotemeta } @phrases; foreach my $sentence ( @sentence_source ) { $sentence =~ s/($phrases_re)/\#$1\#/g; }
(Note the extra map.)
In reply to Re^5: phrase marking
by kyle
in thread phrase marking
by newbio
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |