Problems with regexps
Dennis Reinhardt
DennisR at dair.com
Fri Nov 7 18:10:07 EST 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.
Caveat: untested.
--
Dennis Reinhardt
DennisR at dair.com http://www.spamai.com?ng_py
More information about the Python-list
mailing list