regexp match string with word1 and not word2
Flyzone
flyzone at technologist.com
Wed May 2 04:17:00 EDT 2007
On 30 Apr, 20:00, Steven Bethard <steven.beth... at gmail.com> wrote:
> Well then it seems like you might want to rethink this rule-file
> approach since your problem is clearly not amenable to regular expressions.
[cut]
> That said, here's a regexp that might work::
> ((?!two:).)*one((?!two:).)*
> That makes a negative lookahead assertion at each character in the string.
But match again something so don't work like i wanted.
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.
More information about the Python-list
mailing list