Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Combining multiple =~ s/

by Corion (Patriarch)
on Mar 07, 2021 at 19:10 UTC ( [id://11129292]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %trans = (zero  => 0,
                 one   => 1,
    ...
    
    my $words_re = join "|", map quotemeta, sort { length($b) <=> length($
    +a) } keys %trans;
    $string =~ s/\b($words_re)\b/$trans{lc $1}/ig;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129292]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-16 04:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found