summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-03-10 08:26:53 (GMT)
committerGeorg Brandl <georg@python.org>2012-03-10 08:26:53 (GMT)
commite144c74e023b9caccd0a23ff718028cdd376cddd (patch)
treeb2effe972cc5dfaceaad9efd139274346b735ea9
parent64a40949cf564a690b0263d9b0c18204bceff233 (diff)
downloadcpython-e144c74e023b9caccd0a23ff718028cdd376cddd.zip
cpython-e144c74e023b9caccd0a23ff718028cdd376cddd.tar.gz
cpython-e144c74e023b9caccd0a23ff718028cdd376cddd.tar.bz2
Closes #14244: add info about capturing groups and maxsplit to the docstring of re.split().
-rw-r--r--Lib/re.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/re.py b/Lib/re.py
index 4fe3bd8..3fd59df 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -179,14 +179,19 @@ def subn(pattern, repl, string, count=0, flags=0):
def split(pattern, string, maxsplit=0, flags=0):
"""Split the source string by the occurrences of the pattern,
- returning a list containing the resulting substrings."""
+ 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. If maxsplit is nonzero, at most maxsplit splits occur,
+ and the remainder of the string is returned as the final element
+ of the list."""
return _compile(pattern, flags).split(string, maxsplit)
def findall(pattern, string, flags=0):
"""Return a list of all non-overlapping matches in the string.
- If one or more groups are present in the pattern, return a
- list of groups; this will be a list of tuples if the pattern
+ If one or more capturing groups are present in the pattern, return
+ a list of groups; this will be a list of tuples if the pattern
has more than one group.
Empty matches are included in the result."""