summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libre.tex
diff options
context:
space:
mode:
authorAndrew M. Kuchling <amk@amk.ca>1998-08-14 14:49:20 (GMT)
committerAndrew M. Kuchling <amk@amk.ca>1998-08-14 14:49:20 (GMT)
commitd22e25002a39ac81e7c3232ada2ccef58c0a8fed (patch)
tree6cc2f8d292eb219fca12a96c06b2b889f0192eb8 /Doc/lib/libre.tex
parentce616e4009af0766c2ed848c03a081f29630e807 (diff)
downloadcpython-d22e25002a39ac81e7c3232ada2ccef58c0a8fed.zip
cpython-d22e25002a39ac81e7c3232ada2ccef58c0a8fed.tar.gz
cpython-d22e25002a39ac81e7c3232ada2ccef58c0a8fed.tar.bz2
Clarify wording in the description of re.split
Simplify the patterns in the examples for re.split
Diffstat (limited to 'Doc/lib/libre.tex')
-rw-r--r--Doc/lib/libre.tex10
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/lib/libre.tex b/Doc/lib/libre.tex
index a453fbf..8f41e1a 100644
--- a/Doc/lib/libre.tex
+++ b/Doc/lib/libre.tex
@@ -387,8 +387,8 @@ leftmost such \character{\#} through the end of the line are ignored.
\begin{funcdesc}{split}{pattern, string, \optional{, maxsplit\code{ = 0}}}
Split \var{string} by the occurrences of \var{pattern}. If
- capturing parentheses are used in pattern, then occurrences of
- patterns or subpatterns are also returned.
+ capturing parentheses are used in \var{pattern}, then the text of all
+ groups in the pattern are also returned as part of the resulting list.
If \var{maxsplit} is nonzero, at most \var{maxsplit} splits
occur, and the remainder of the string is returned as the final
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.
later releases.)
%
\begin{verbatim}
->>> re.split('[\W]+', 'Words, words, words.')
+>>> re.split('\W+', 'Words, words, words.')
['Words', 'words', 'words', '']
->>> re.split('([\W]+)', 'Words, words, words.')
+>>> re.split('(\W+)', 'Words, words, words.')
['Words', ', ', 'words', ', ', 'words', '.', '']
->>> re.split('[\W]+', 'Words, words, words.', 1)
+>>> re.split('\W+', 'Words, words, words.', 1)
['Words', 'words, words.']
\end{verbatim}
%