On Sun, 15 Aug 2010 17:36:07 -0700, 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.
Pardon me, but that's clearly not correct, as proven by the fact that the above example works. You can say that the flags *should* go at the start, for the sake of efficiency, or ease of comprehension, or tradition, or to appease the Regex Cops who roam the streets beating up those who don't write regexes in the approved fashion. But it isn't true that they *must* go at the front. -- Steven -- http://mail.python.org/mailman/listinfo/python-list