Help for this page

Select Code to Download


  1. or download this
    $string =~ s/(a|b)/$map{ $1 }/g;
    
  2. or download this
    $pattern = join '|', map quotemeta, keys %map;
    $string =~ s/($pattern)/$map{ $1 }/go;  # /o only if the pattern never
    + changes
    
  3. or download this
    use Regex::PreSuf;
    my $pattern= presuf(keys %map);
    $string =~ s/($pattern)/$map{ $1 }/go;
    
  4. or download this
    $pattern = join '|', map quotemeta, sort { length($b) <=> length($a) }
    + keys %map;
    
  5. or download this
    $pattern = join '|', map quotemeta, sort { $b cmp $a } keys %map;