]> granicus.if.org Git - python/commitdiff
Clarify wording in the description of re.split
authorAndrew M. Kuchling <amk@amk.ca>
Fri, 14 Aug 1998 14:49:20 +0000 (14:49 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Fri, 14 Aug 1998 14:49:20 +0000 (14:49 +0000)
Simplify the patterns in the examples for re.split

Doc/lib/libre.tex

index a453fbf3a9caa6db99ee28bca47a36116c3470a7..8f41e1ae98b933f6965098887608535cc6daaa8c 100644 (file)
@@ -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}
 %