Alex Willmer wrote:
On Aug 16, 1:07 am, Steven D'Aprano <st...@remove-this-
cybersource.com.au> wrote:
You're passing re.IGNORECASE (which happens to equal 2) as a count
argument, not as a flag. Try this instead:

re.sub(r"python\d\d" + '(?i)', "Python27", t)
'Python27'

Basically right, but in-line flags must be placed at the start of a
pattern, or the result is undefined. Also in Python 2.7 re.sub() has a
flags argument.

[snip]
In re such flags apply to the entire regex, no matter where they appear.
This even applies to the (?x) (VERBOSE) flag; if re sees it at the end
of the regex then it has to re-scan the entire regex!

For clarity and compatibility with other regex implementations, put it
initially.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to