On Tue, Oct 23, 2012 at 1:51 PM, MartinD. <cyberdi...@gmail.com> wrote:
> Hi,
>
> I'm new to Python.
> Does someone has an idea what's wrong.  I tried everything. The only regex 
> that is tested is the last one in a whole list of regex in keywords.txt
> Thanks!
> Martin

How do you know that it's the only one being tested?  Your debugging
statement only prints one that actually matches, not each one that is
tried.

> keywords1 = [line for line in open('keywords1.txt')]

Note that each "keyword" will including the trailing newline, if any.
This is probably why you are only seeing the last keyword match:
because it is the only one without a trailing newline.

To remove the newlines, call the str.strip or str.rstrip method on
each line, or use the str.splitlines method to get the keywords:

keywords1 = open('keywords1.txt').read().splitlines()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to