How make regex that means "contains regex#1 but NOT regex#2" ??

A.T.Hofkamp hat at se-162.se.wtb.tue.nl
Tue Jul 1 09:34:13 CEST 2008


On 2008-07-01, seberino at spawar.navy.mil <seberino at spawar.navy.mil> wrote:
> I'm looking over the docs for the re module and can't find how to
> "NOT" an entire regex.

(?! R)

> How make regex that means "contains regex#1 but NOT regex#2" ?

(\1|(?!\2))

should do what you want.

Albert



More information about the Python-list mailing list