regexp match string with word1 and not word2

Steven Bethard steven.bethard at gmail.com
Mon Apr 30 14:00:26 EDT 2007


Flyzone wrote:
> On 30 Apr, 17:11, Steven Bethard <steven.beth... at gmail.com> wrote:
> 
>> You don't need a regexp:;
> 
> I need a regexp.....i'm parsing a file with a rule-file that contains
> also regexp and strings too....

Well then it seems like you might want to rethink this rule-file 
approach since your problem is clearly not amenable to regular expressions.

That said, here's a regexp that might work::

     ((?!two:).)*one((?!two:).)*

That makes a negative lookahead assertion at each character in the string.

STeVe



More information about the Python-list mailing list