Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: build regexp on a list of patterns

by ysth (Canon)
on Apr 06, 2005 at 09:08 UTC ( [id://445218]=note: print w/replies, xml ) Need Help??


in reply to Re: build regexp on a list of patterns
in thread build regexp on a list of patterns

my $re = do { local $" = '|'; qr/^@{[map {quotemeta} @list]}$/; };
In this case, it would appear that they are all the same length, but in general, the list should be sorted longest-first, so that @list=qw/foo bar foobar/ will ever match foobar.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (10)
As of 2024-04-18 14:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found