Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Steven D'Aprano
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(rpython\d\d + '(?i)', Python27, t)

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Christopher
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(rpython\d\d, Python27, t) 'Python26' re.sub(rpython\d\d, Python27, t, re.IGNORECASE)

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Alex Willmer
On Aug 16, 12:23 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: 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

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Alex Willmer
On Aug 16, 1:46 pm, Alex Willmer a...@moreati.org.uk wrote: Note that the (?x) flag changes how the expression is parsed. It should be used first in the expression string, or after one or more whitespace characters. If there are non-whitespace characters before the flag, the results are

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 05:46:17 -0700, Alex Willmer wrote: On Aug 16, 12:23 pm, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: 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

Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-15 Thread Christopher
I have the following problem: Python 2.7 (r27:82525, Jul 4 2010, 07:43:08) [MSC v.1500 64 bit (AMD64)] on win32 Type help, copyright, credits or license for more information. t=Python26 import re re.sub(rpython\d\d, Python27, t) 'Python26' re.sub(rpython\d\d, Python27, t, re.IGNORECASE)

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-15 Thread Steven D'Aprano
On Sun, 15 Aug 2010 16:45:49 -0700, Christopher wrote: I have the following problem: t=Python26 import re re.sub(rpython\d\d, Python27, t) 'Python26' re.sub(rpython\d\d, Python27, t, re.IGNORECASE) 'Python26' re.sub(rPython\d\d, Python27, t, re.IGNORECASE) 'Python27' Is this a known

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-15 Thread Alex Willmer
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(rpython\d\d + '(?i)', Python27, t) 'Python27' Basically right, but in-line flags must be

Re: Python 2.7 re.IGNORECASE broken in re.sub?

2010-08-15 Thread MRAB
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(rpython\d\d + '(?i)', Python27, t) 'Python27' Basically right, but