Fix replacements (again). Add tests to test words and sequences with punctuation. Fixes bug #12208.

This commit is contained in:
Colin Kuskie 2011-08-01 10:27:43 -07:00
parent 1cc7ac2578
commit a3ff0fb7a5
3 changed files with 35 additions and 5 deletions

View file

@ -397,7 +397,11 @@ sub processReplacements {
}
foreach my $searchFor (keys %{$replacements}) {
my $replaceWith = $replacements->{$searchFor};
$content =~ s/\b\Q$searchFor\E\b/$replaceWith/gs;
my $pattern = qr/\Q$searchFor\E/;
if ($searchFor =~ /^\w+/) {
$pattern = qr/\b$pattern\b/;
}
$content =~ s/$pattern/$replaceWith/gs;
}
return $content;
}