in reply to Matching an array of regexes (grep in reverse)
grep { $string =~ /$_/ } @regex;
and if you don't need to count how many matches occured than you can speed up that code:
Updated: (thx to Anomalous Monk)
sub is_match { grep { $string =~ /$_/ and return 1 } @regex; } if ( is_match() ) { print qq($string matched some regex); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching an array of regexes (grep in reverse)
by AnomalousMonk (Archbishop) on Nov 20, 2008 at 20:58 UTC | |
|
Re^2: Matching an array of regexes (grep in reverse)
by raymor (Acolyte) on Nov 20, 2008 at 20:52 UTC |