Matching an array of strings to strings in a file.

Martin A. Brooks martin at antibodymx.net
Mon Aug 29 12:21:31 BST 2011


Hello

This seems like it should be a non-lazyweb question, but Google doesn't seem to be co-operating.

I have an array of strings.  I have some plain text files on disk.  I want to see if any of the lines in the text files contain any of the strings in the array.  I can stop as soon as I find one match.

There's the obvious brute force way of un-newlining the text file so it's just one long string and then walking the array top to bottom, but that seems ugly.

Any bright ideas?

Thanks

-- 
Martin A. Brooks
http://antibodyMX.net/ - antispam & antivirus email filtering.


More information about the london.pm mailing list