classification
Title: SRE: (?flag) isn't properly scoped
Type: feature request Stage:
Components: Regular Expressions Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Major reworking of Python 2.5.2 re module
View: 3825
Superseder:
Assigned To: effbot Nosy List: belopolsky, effbot, mrabarnett, rsc, timehorse (5)
Priority: low Keywords

Created on 2001-06-14 08:26 by effbot, last changed 2009-02-12 19:35 by ajaksu2.

Messages (3)
msg53160 - (view) Author: Fredrik Lundh (effbot) Date: 2001-06-14 08:26
from the jeffrey friedl report:

The way (?i) works now is that if it appears anywhere 
in the regex, it turns on case-insensative matching 
for the entire regex. This is different (and less 
useful) than how Perl or Sun's Java package does it

[I'm pretty sure SRE does it this way to exactly
match the version of PCRE used in 1.5.2, but maybe
it's time to move forward... /F]
msg63644 - (view) Author: Alexander Belopolsky (belopolsky) Date: 2008-03-17 14:01
This is still a valid issue. (As of Python 2.6a1+ (trunk:61434, Mar 17 
2008, 08:06:54).)

>>> bool(re.match("abc(?i)","AbC"))
True

The documentation says that the behavior of a regex with (?<letter>) not 
at the beginning is undefined.

Short of implementing Java/Perl behavior, this should be made an error 
rather than undefined so that users porting their code from Java/Perl 
get an early warning.
msg73685 - (view) Author: Matthew Barnett (mrabarnett) Date: 2008-09-24 00:38
Implemenetd in #3825.
History
Date User Action Args
2009-02-12 19:35:13ajaksu2setdependencies: + Major reworking of Python 2.5.2 re module
versions: + Python 2.6
2008-09-24 11:28:31timehorsesetnosy: + timehorse
2008-09-24 00:38:24mrabarnettsetnosy: + mrabarnett
messages: + msg73685
2008-04-24 21:12:50rscsetnosy: + rsc
2008-03-17 14:01:51belopolskysetnosy: + belopolsky
messages: + msg63644
2001-06-14 08:26:00effbotcreate