On Aug 15, 8:07 pm, Steven D'Aprano <st...@remove-this- cybersource.com.au> wrote: > On Sun, 15 Aug 2010 16:45:49 -0700, Christopher wrote: > > I have the following problem: > > >>>> t="Python26" > >>>> import re > >>>> re.sub(r"python\d\d", "Python27", t) > > 'Python26' > >>>> re.sub(r"python\d\d", "Python27", t, re.IGNORECASE) > > 'Python26' > >>>> re.sub(r"Python\d\d", "Python27", t, re.IGNORECASE) > > 'Python27' > > Is this a known bug? Is it by design for some odd reason? > >>> help(re.sub) > > Help on function sub in module re: > > sub(pattern, repl, string, count=0) > ... > > 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' >
Thanks. Somehow I didn't notice that other argument after looking at it a million times. :-) -- http://mail.python.org/mailman/listinfo/python-list