Problems with regexps
DennisR at dair.com
Sat Nov 8 00:10:07 CET 2003
> sample = 'FOO= BAR'
> if re.search(r'[^=]\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.
DennisR at dair.com http://www.spamai.com?ng_py
More information about the Python-list