Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: build regexp on a list of patterns

by Zaxo (Archbishop)
on Apr 06, 2005 at 08:47 UTC ( [id://445211]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $re = do {
        local $" = '|';
        qr/^@{[map {quotemeta} @list]}$/;
    };
    
  2. or download this
    my @sets;
    for (@list) {
        my $str = $_;
    ...
        }
    }
    my $re = qr/^${\join '', map {"[$_]"} @sets}$/;
    
  3. or download this
    {
        my %test_hash;
        @test_hash{@list} = ();
        sub efficient_test { exists $test_hash{+shift}; }
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2024-03-28 12:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found