Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Need help comparing against a set of regexps

by gellyfish (Monsignor)
on Mar 10, 2002 at 10:13 UTC ( #150701=note: print w/replies, xml ) Need Help??


in reply to Need help comparing against a set of regexps

You can cut out the loop by doing something like:

my @regexes = ('hello(\w+)','foo(\d+)','zubbble(.*)'); my $re = join '|', sort { length $b <=> length $a } @regexes; $re = "(?:$re)"; print "Matched!\n" if 'foo123' =~ /$re/;
Check out the perlre manpage for more on how this works.

/J\

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (1)
As of 2022-01-29 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (74 votes). Check out past polls.

    Notices?