Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e144c74

Browse files
committed
Closes #14244: add info about capturing groups and maxsplit to the docstring of re.split().
1 parent 64a4094 commit e144c74

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Lib/re.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,19 @@ def subn(pattern, repl, string, count=0, flags=0):
179179

180180
def split(pattern, string, maxsplit=0, flags=0):
181181
"""Split the source string by the occurrences of the pattern,
182-
returning a list containing the resulting substrings."""
182+
returning a list containing the resulting substrings. If
183+
capturing parentheses are used in pattern, then the text of all
184+
groups in the pattern are also returned as part of the resulting
185+
list. If maxsplit is nonzero, at most maxsplit splits occur,
186+
and the remainder of the string is returned as the final element
187+
of the list."""
183188
return _compile(pattern, flags).split(string, maxsplit)
184189

185190
def findall(pattern, string, flags=0):
186191
"""Return a list of all non-overlapping matches in the string.
187192
188-
If one or more groups are present in the pattern, return a
189-
list of groups; this will be a list of tuples if the pattern
193+
If one or more capturing groups are present in the pattern, return
194+
a list of groups; this will be a list of tuples if the pattern
190195
has more than one group.
191196
192197
Empty matches are included in the result."""

0 commit comments

Comments
 (0)