Match 2 words in a line of file

Rickard Lindberg ricli576 at student.liu.se
Thu Jan 18 21:54:59 EST 2007


I see two potential problems with the non regex solutions.

1) Consider a line: "foo (bar)". When you split it you will only get
two strings, as split by default only splits the string on white space
characters. Thus "'bar' in words" will return false, even though bar is
a word in that line.

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).




More information about the Python-list mailing list