Commit 510d9b87 authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

Clarify wording in the description of re.split

Simplify the patterns in the examples for re.split
parent e5ed5b35
...@@ -387,8 +387,8 @@ leftmost such \character{\#} through the end of the line are ignored. ...@@ -387,8 +387,8 @@ leftmost such \character{\#} through the end of the line are ignored.
\begin{funcdesc}{split}{pattern, string, \optional{, maxsplit\code{ = 0}}} \begin{funcdesc}{split}{pattern, string, \optional{, maxsplit\code{ = 0}}}
Split \var{string} by the occurrences of \var{pattern}. If Split \var{string} by the occurrences of \var{pattern}. If
capturing parentheses are used in pattern, then occurrences of capturing parentheses are used in \var{pattern}, then the text of all
patterns or subpatterns are also returned. groups in the pattern are also returned as part of the resulting list.
If \var{maxsplit} is nonzero, at most \var{maxsplit} splits If \var{maxsplit} is nonzero, at most \var{maxsplit} splits
occur, and the remainder of the string is returned as the final occur, and the remainder of the string is returned as the final
element of the list. (Incompatibility note: in the original Python element of the list. (Incompatibility note: in the original Python
...@@ -396,11 +396,11 @@ leftmost such \character{\#} through the end of the line are ignored. ...@@ -396,11 +396,11 @@ leftmost such \character{\#} through the end of the line are ignored.
later releases.) later releases.)
% %
\begin{verbatim} \begin{verbatim}
>>> re.split('[\W]+', 'Words, words, words.') >>> re.split('\W+', 'Words, words, words.')
['Words', 'words', 'words', ''] ['Words', 'words', 'words', '']
>>> re.split('([\W]+)', 'Words, words, words.') >>> re.split('(\W+)', 'Words, words, words.')
['Words', ', ', 'words', ', ', 'words', '.', ''] ['Words', ', ', 'words', ', ', 'words', '.', '']
>>> re.split('[\W]+', 'Words, words, words.', 1) >>> re.split('\W+', 'Words, words, words.', 1)
['Words', 'words, words.'] ['Words', 'words, words.']
\end{verbatim} \end{verbatim}
% %
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment