On 18 Jan 2007 18:54:59 -0800, "Rickard Lindberg"
<[EMAIL PROTECTED]> wrote:

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

1) Depends how you define a 'word'.

2) This can be resolved with

templine = ' ' + line + ' '
if ' ' + word1 + ' ' in templine and ' ' + word2 + ' ' in templine:


Dan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to