Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: regex with arrays and variables

by moritz (Cardinal)
on Apr 25, 2013 at 18:22 UTC ( #1030715=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my $regex = "(";
    foreach (@array2) {
      $regex .= $_ . "|";
    }
    $regex .= ")";
    
  2. or download this
    my $regex = join '|', @array2;
    
  3. or download this
    my $regex = join '|', map quotemeta, @array2;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2014-07-29 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls