classification
Title: No information about behaviour with groups in pattern in the docstring for re.split
Type: enhancement Stage: resolved
Components: Documentation, Regular Expressions Versions: Python 3.2, Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Ramchandra Apte, docs@python, ezio.melotti, georg.brandl, mrabarnett, py.user, python-dev
Priority: normal Keywords:

Created on 2012-03-10 03:08 by Ramchandra Apte, last changed 2012-04-29 05:17 by ezio.melotti. This issue is now closed.

Messages (5)
msg155286 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-03-10 03:08
help(re.split)

"split(pattern, string, maxsplit=0, flags=0)
    Split the source string by the occurrences of the pattern,
    returning a list containing the resulting substrings."


No info is given about behaviour with groups in pattern.
Created because of http://bugs.python.org/issue14236#msg155283.
msg155288 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2012-03-10 03:10
Oops. The link in the last sentence doesn't work.
It should be see msg155283 .
msg155297 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-03-10 08:23
New changeset b96251d9f36a by Georg Brandl in branch '3.2':
Closes #14244: add info about capturing groups and maxsplit to the docstring of re.split().
http://hg.python.org/cpython/rev/b96251d9f36a
msg155298 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2012-03-10 08:24
Thank you, should be fixed now.
msg155299 - (view) Author: py.user (py.user) * Date: 2012-03-10 08:42
"+    returning a list containing the resulting substrings.  If
+    capturing parentheses are used in pattern, then the text of all
+    groups in the pattern are also returned as part of the resulting
+    list."

not only text

>>> import re
>>> re.split(r'(a)(x)?', 'abcabc')
['', 'a', None, 'bc', 'a', None, 'bc']
>>>
History
Date User Action Args
2012-04-29 05:17:35ezio.melottisetstage: resolved
type: enhancement
versions: + Python 3.3
2012-03-10 08:42:14py.usersetmessages: + msg155299
2012-03-10 08:24:22georg.brandlsetnosy: + georg.brandl

messages: + msg155298
stage: resolved -> (no value)
2012-03-10 08:23:28python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg155297

resolution: fixed
stage: resolved
2012-03-10 04:52:48py.usersetnosy: + mrabarnett, py.user, ezio.melotti

components: + Regular Expressions
versions: + Python 3.2
2012-03-10 03:10:49Ramchandra Aptesetmessages: + msg155288
2012-03-10 03:08:21Ramchandra Aptecreate