Rickard Lindberg, yesterday I was sleepy and my solution was wrong. > 2) If you have a line something like this: "foobar hello" then "'foo' > in line" will return true, even though foo is not a word (it is part of > a word).
Right. Now I think the best solution is to use __contains__ (in) to quickly find the lines that surely contains both substrings, then on such possibly rare cases you can use a correctly done RE. If the words are uncommon enough, such solution may be fast and reliable. Using raw tests followed by slow and reliable ones on the rare positive results of the first test is a solution commonly used in Computer Science, that often is both fast and reliable. (It breaks when the first test is passed too much often, or when it has some false negatives). Probably there are even faster solutions, scanning the whole text at once instead of inside its lines, but the code becomes too much hairy and probably it's not worth it. Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list