in reply to RegExp to Search All Array Members?
my $regexStr="^static\s+\w+\s+(" # Thanks moritz! . (join "|",map quotemeta,@names) . ")\W.*)"; while(<STDIN>) { chomp; if(/$regexStr/) { # rest is the same as your "optimized" # attempt
Edit: added map quotemeta as suggested by moritz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RegExp to Search All Array Members?
by moritz (Cardinal) on Jun 19, 2007 at 10:26 UTC | |
|
Re^2: RegExp to Search All Array Members?
by ff (Hermit) on Jun 19, 2007 at 13:19 UTC | |
by Aceflex (Initiate) on Jan 03, 2012 at 23:33 UTC | |
by Anonymous Monk on Aug 16, 2012 at 20:42 UTC | |
|
Re^2: RegExp to Search All Array Members?
by johngg (Canon) on Jun 19, 2007 at 13:33 UTC |