Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: hashes in regexes

by tadman (Prior)
on Mar 29, 2001 at 04:12 UTC ( #68010=note: print w/ replies, xml ) Need Help??


in reply to Re: hashes in regexes
in thread hashes in regexes

I'm not sure about the application, but it might be advisable to at least put in some '\b's to prevent unfortunate collisions that would render some names as "Mikestone", or "Moeseph".

Here is a slight modification of japhy's (or merlyn's, you decide) code:

$keys = join '|', map "\\b\Q$_\E\\b", keys %sub_hash; $keys_REx = qr/$keys/; $string =~ s/($keys_REx)/$sub_hash{$1}/g;


Comment on Re^2: hashes in regexes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (13)
As of 2015-05-28 14:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    In my home, the TV remote control is ...









    Results (559 votes), past polls