This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: re.split, re.sub and re.subn should support flags
Type: enhancement Stage: resolved
Components: Regular Expressions Versions: Python 3.2
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: benoit, mjkeeler7, pitrou, r.david.murray, rhettinger, timehorse
Priority: normal Keywords: easy

Created on 2008-08-01 07:20 by benoit, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg70543 - (view) Author: Benoit T (benoit) Date: 2008-08-01 07:20
Given that the search operations support flags, it seems natural for a
developer that the other functions in the module support flags as well.
So when running "re.split(pattern, string, re.I)", the split() command
seems to not work and don't return a message error (I understand that
're.I' is understood as 'maxsplit=0'.)

This is confusing and I think that it should be changed so that all
functions in the module are consistent.
msg71166 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-15 10:16
Please note that the flags can be inlined in the pattern instead. That
is, you can begin the pattern with "(?i)" instead of passing re.I in the
flags parameter.
msg113637 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-08-11 22:22
This request seems reasonable.
msg118611 - (view) Author: Matt Keeler (mjkeeler7) Date: 2010-10-14 02:26
Python 2.7 docs say this was added in
Python 3.1 docs say this was added in 3.1

The problem with calling 're.split(pattern, string, re.I)' is that you are using positional arguments only.  If you were to do 're.split(pattern, string, flags=re.I)', that should produce the desired result.
msg118912 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-10-17 03:17
For reference, the py3k rev was r70091.
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47732
2010-10-17 03:17:26r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg118912

resolution: accepted
stage: needs patch -> resolved
2010-10-14 02:26:04mjkeeler7setnosy: + mjkeeler7
messages: + msg118611
2010-08-12 11:34:29pitrousetstage: test needed -> needs patch
2010-08-11 22:22:37rhettingersetkeywords: + easy
nosy: + rhettinger
messages: + msg113637

2010-08-09 03:10:51terry.reedysetstage: test needed
versions: + Python 3.2, - Python 3.1, Python 2.7
2008-09-27 14:25:42timehorsesetversions: + Python 3.1, Python 2.7, - Python 2.6, Python 3.0
2008-09-27 14:23:14timehorsesetnosy: + timehorse
2008-08-15 10:16:46pitrousetpriority: normal
type: behavior -> enhancement
messages: + msg71166
nosy: + pitrou
versions: + Python 2.6, Python 3.0
2008-08-01 07:20:37benoitsettype: behavior
components: + Regular Expressions
2008-08-01 07:20:21benoitcreate