I saw this previous post about matching with multiple regular expressions. How can I match with multiple regular expressions in Perl?
I am looking for the fastest way to match all the values ββcontained in an array with a very large file (500 MB).
Patterns are read from stdin and may contain special characters that should be used in the regular expression (bindings, character classes, etc.). Matching should occur when all patterns are contained in the current line.
I am currently using a nested loop, but I'm not very happy with the speed ....
Thanks for your suggestions.
grep?
while($line=<>) { if (scalar(grep($line=~/$_/,@regexps))==scalar(@regexps)) { # ... All matched } }
Regexp:: Assemble, , , grep. Regexp:: Assemble , Perl , . , ymmv.
grep
Perl, , . 5.10 (. " try" ). -, SpamAssassin, , , , Regexp:: Assemble.
, , , grep -P -f $regex_file $big_file. -P grep , Perl. , . grep Perl.
grep -P -f $regex_file $big_file
-P
, .