Regexp Neg. set of chars HowTo?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Dec 22 07:23:26 EST 2006


In <mailman.1946.1166786976.32031.python-list at python.org>, durumdara
wrote:

> I found a solution my question in regexp way too:
> import re
> testtext = " minion battalion nation dion sion wion alion"
> m = re.compile("[^t^l]ion")
> print m.findall(testtext)
> 
> I search for all text that not lion and tion.

And ^ion.  The first ^ in that character group "negates" that group, the
second is a literal ^, so I guess you meant "[^tl]ion".

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list