http://qs321.pair.com?node_id=11129291


in reply to Combining multiple =~ s/

Let Perl generate the regular expression from a hash containing the list of words and their replacements:
my %trans = (zero => 0, one => 1, two => 2, three => 3); my $words_re = join "|", map quotemeta, keys %trans; $string =~ s/($words_re)/$trans{lc $1}/ig;