Problems with regexps

Dennis Reinhardt DennisR at
Sat Nov 8 00:10:07 CET 2003

>     sample = 'FOO= BAR'
>     if'[^=]\s*BAR', sample):
>         print 'Match 2.'

The [^=] will match on the space preceding BAR.  The \s* matches because
there are zero spaces remaining.  Result: match.

Prediction: you can get the first expression to fail by putting in two
spaces, not one.

Caveat: untested.

Dennis Reinhardt

DennisR at

More information about the Python-list mailing list