change to note between 2.0 and 2.1
Tavis Rudd
tavis at calrudd.com
Wed Jun 6 18:40:36 EDT 2001
Hi Andrew,
the re module handles negative
look-behinds differently in 2.1 and 2.0. In 2.1 a
negative look-behind at the very beginning of a string
will match if the rest of the following text matches. In 2.0
this doesn't match. Would you mind adding a note about
this on the "What's New in Python 2.1" page?
example
=========================================
Try to match all $, but not \$, in the following string.
"$ $ $ \$"
Using re.compile(r"(?<!\\)\$"), Python 2.1 finds 3,
Python 2.0 finds 2.
Using re.compile(r"(?:(?<=\A)|(?<!\\))\$"), both versions
find 3.
=========================================
Cheers,
Tavis
More information about the Python-list
mailing list