]> granicus.if.org Git - python/commitdiff
Added thread unsafety warning. Added optional retain arg to split.
authorGuido van Rossum <guido@python.org>
Wed, 26 Jun 1996 19:24:22 +0000 (19:24 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 26 Jun 1996 19:24:22 +0000 (19:24 +0000)
Doc/lib/libregsub.tex
Doc/libregsub.tex

index 5747e4f99bb767c5f6de9678fcdab2f14f135b06..bbb7671678a28b69b5a75e1bf50c4a5697746531 100644 (file)
@@ -4,6 +4,8 @@
 This module defines a number of functions useful for working with
 regular expressions (see built-in module \code{regex}).
 
+Warning: these functions are not thread-safe.
+
 \renewcommand{\indexsubitem}{(in module regsub)}
 \begin{funcdesc}{sub}{pat\, repl\, str}
 Replace the first occurrence of pattern \var{pat} in string
@@ -21,10 +23,13 @@ when not adjacent to a previous match, so e.g.
 \code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
 \end{funcdesc}
 
-\begin{funcdesc}{split}{str\, pat}
+\begin{funcdesc}{split}{str\, pat\optional{\, retain}}
 Split the string \var{str} in fields separated by delimiters matching
 the pattern \var{pat}, and return a list containing the fields.  Only
 non-empty matches for the pattern are considered, so e.g.
 \code{split('a:b', ':*')} returns \code{['a', 'b']} and
 \code{split('abc', '')} returns \code{['abc']}.
+If the optional \var{retain} argument is true, the separators are also
+inserted in the list, so e.g. \code{split('a:::b', ':*', 1)} returns
+\code{['a', ':::', 'b']}.
 \end{funcdesc}
index 5747e4f99bb767c5f6de9678fcdab2f14f135b06..bbb7671678a28b69b5a75e1bf50c4a5697746531 100644 (file)
@@ -4,6 +4,8 @@
 This module defines a number of functions useful for working with
 regular expressions (see built-in module \code{regex}).
 
+Warning: these functions are not thread-safe.
+
 \renewcommand{\indexsubitem}{(in module regsub)}
 \begin{funcdesc}{sub}{pat\, repl\, str}
 Replace the first occurrence of pattern \var{pat} in string
@@ -21,10 +23,13 @@ when not adjacent to a previous match, so e.g.
 \code{gsub('', '-', 'abc')} returns \code{'-a-b-c-'}.
 \end{funcdesc}
 
-\begin{funcdesc}{split}{str\, pat}
+\begin{funcdesc}{split}{str\, pat\optional{\, retain}}
 Split the string \var{str} in fields separated by delimiters matching
 the pattern \var{pat}, and return a list containing the fields.  Only
 non-empty matches for the pattern are considered, so e.g.
 \code{split('a:b', ':*')} returns \code{['a', 'b']} and
 \code{split('abc', '')} returns \code{['abc']}.
+If the optional \var{retain} argument is true, the separators are also
+inserted in the list, so e.g. \code{split('a:::b', ':*', 1)} returns
+\code{['a', ':::', 'b']}.
 \end{funcdesc}