Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: matching a regular expression

by japhy (Canon)
on May 18, 2006 at 17:49 UTC ( [id://550302]=note: print w/replies, xml ) Need Help??


in reply to Re^3: matching a regular expression
in thread matching a regular expression

What I meant was, writing "h|hs|hsb|hsbn" yourself is tedious. Better to have Perl generate that for you:
my %abbrevs = map { my $word = $_; ($word => join("|", map { substr($word, 1, $_) } 1 .. length($word) +})) } qw( hsbn admin ... );

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Replies are listed 'Best First'.
Re^5: matching a regular expression
by HuckinFappy (Pilgrim) on May 18, 2006 at 18:27 UTC
    Thanks. I agree it seemed tedious, but no better method was jumping to mind. I like that solution!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-25 15:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found