regexp match string with word1 and not word2

Ant antroy at gmail.com
Wed May 2 11:16:51 EDT 2007


On May 2, 9:17 am, Flyzone <flyz... at technologist.com> wrote:
> On 30 Apr, 20:00, Steven Bethard <steven.beth... at gmail.com> wrote:
...
> Maybe a right approach will be another if after the first one? Like:
>    for y in range(0, len(skip_lst) ):
>                  if (re.search(skip_lst[y], line)):
>                                      if
> (re.search(skip_lst_negative[y], line)):
>                                                    skip=1
>                                                    break
> and in the rule-file, i could add a new column and check to do the if
> just if the second column is not empty.

This is quite a common approach for this sort of matching problem -
having includes and excludes patterns, and having the test return True
if the include matches but not the exclude. Trying to roll the two
into one requires pretty unreadable regexes if it is possible at all...




More information about the Python-list mailing list