I want to exclude an expression of a sequence of charecters with regex

Fredrik Lundh fredrik at pythonware.com
Tue Dec 27 10:42:23 EST 2005


"28tommy" wrote:

> I know how to exclude 1 charecter from a compiled sequence of the re
> module- '[^a]', but if I want to exclude a word or a sequence as one
> unit (not as separate charecters) to be checked.... how do I do that?
>
> I tried re.compile('[^(abc)]')
> ... or re.compile('[^a][^b][^c]')
> ... or re.compile('[^a^b^c]')
> None of these worked.

look for "negative lookahead assertion" on this page:

    http://docs.python.org/lib/re-syntax.html

</F>






More information about the Python-list mailing list