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

Skip to content

Commit d22e250

Browse files
committed
Clarify wording in the description of re.split
Simplify the patterns in the examples for re.split
1 parent ce616e4 commit d22e250

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

Doc/lib/libre.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -387,20 +387,20 @@ \subsection{Module Contents}
387387

388388
\begin{funcdesc}{split}{pattern, string, \optional{, maxsplit\code{ = 0}}}
389389
Split \var{string} by the occurrences of \var{pattern}. If
390-
capturing parentheses are used in pattern, then occurrences of
391-
patterns or subpatterns are also returned.
390+
capturing parentheses are used in \var{pattern}, then the text of all
391+
groups in the pattern are also returned as part of the resulting list.
392392
If \var{maxsplit} is nonzero, at most \var{maxsplit} splits
393393
occur, and the remainder of the string is returned as the final
394394
element of the list. (Incompatibility note: in the original Python
395395
1.5 release, \var{maxsplit} was ignored. This has been fixed in
396396
later releases.)
397397
%
398398
\begin{verbatim}
399-
>>> re.split('[\W]+', 'Words, words, words.')
399+
>>> re.split('\W+', 'Words, words, words.')
400400
['Words', 'words', 'words', '']
401-
>>> re.split('([\W]+)', 'Words, words, words.')
401+
>>> re.split('(\W+)', 'Words, words, words.')
402402
['Words', ', ', 'words', ', ', 'words', '.', '']
403-
>>> re.split('[\W]+', 'Words, words, words.', 1)
403+
>>> re.split('\W+', 'Words, words, words.', 1)
404404
['Words', 'words, words.']
405405
\end{verbatim}
406406
%

0 commit comments

Comments
 (0)