summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1996-08-09 21:43:21 (GMT)
committerGuido van Rossum <guido@python.org>1996-08-09 21:43:21 (GMT)
commit0b3f9512ac8b4630aaf87bd9e7fbe6e65fffaeb4 (patch)
tree03888a05a7ec07538ce29ade146f0aa7324eac8a
parent7a7d5d8fcf5ac8f9eaf8016da04984687e43dae3 (diff)
downloadcpython-0b3f9512ac8b4630aaf87bd9e7fbe6e65fffaeb4.zip
cpython-0b3f9512ac8b4630aaf87bd9e7fbe6e65fffaeb4.tar.gz
cpython-0b3f9512ac8b4630aaf87bd9e7fbe6e65fffaeb4.tar.bz2
Added capwords, splitx, and optional 3rd argument to split/splitx.
-rw-r--r--Doc/lib/libregsub.tex26
-rw-r--r--Doc/libregsub.tex26
2 files changed, 42 insertions, 10 deletions
diff --git a/Doc/lib/libregsub.tex b/Doc/lib/libregsub.tex
index bbb7671..4c1497c 100644
--- a/Doc/lib/libregsub.tex
+++ b/Doc/lib/libregsub.tex
@@ -7,6 +7,7 @@ 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
\var{str} by replacement \var{repl}. If the pattern isn't found,
@@ -23,13 +24,28 @@ 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\optional{\, retain}}
+\begin{funcdesc}{split}{str\, pat\optional{\, maxsplit}}
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']}.
+\code{split('abc', '')} returns \code{['abc']}. The \var{maxsplit}
+defaults to 0. If it is nonzero, only \var{maxsplit} number of splits
+occur, and the remainder of the string is returned as the final
+element of the list.
+\end{funcdesc}
+
+\begin{funcdesc}{splitx}{str\, pat\optional{\, maxsplit}}
+Split the string \var{str} in fields separated by delimiters matching
+the pattern \var{pat}, and return a list containing the fields as well
+as the separators. For example, \code{splitx('a:::b', ':*')} returns
+\code{['a', ':::', 'b']}. Otherwise, this function behaves the same
+as \code{split}.
+\end{funcdesc}
+
+\begin{funcdesc}{capwords}{s\optional{\, pat}}
+Capitalize words separated by optional pattern \var{pat}. The default
+pattern uses any characters except letters, digits and underscores as
+word delimiters. Capitalization is done by changing the first
+character of each word to upper case.
\end{funcdesc}
diff --git a/Doc/libregsub.tex b/Doc/libregsub.tex
index bbb7671..4c1497c 100644
--- a/Doc/libregsub.tex
+++ b/Doc/libregsub.tex
@@ -7,6 +7,7 @@ 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
\var{str} by replacement \var{repl}. If the pattern isn't found,
@@ -23,13 +24,28 @@ 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\optional{\, retain}}
+\begin{funcdesc}{split}{str\, pat\optional{\, maxsplit}}
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']}.
+\code{split('abc', '')} returns \code{['abc']}. The \var{maxsplit}
+defaults to 0. If it is nonzero, only \var{maxsplit} number of splits
+occur, and the remainder of the string is returned as the final
+element of the list.
+\end{funcdesc}
+
+\begin{funcdesc}{splitx}{str\, pat\optional{\, maxsplit}}
+Split the string \var{str} in fields separated by delimiters matching
+the pattern \var{pat}, and return a list containing the fields as well
+as the separators. For example, \code{splitx('a:::b', ':*')} returns
+\code{['a', ':::', 'b']}. Otherwise, this function behaves the same
+as \code{split}.
+\end{funcdesc}
+
+\begin{funcdesc}{capwords}{s\optional{\, pat}}
+Capitalize words separated by optional pattern \var{pat}. The default
+pattern uses any characters except letters, digits and underscores as
+word delimiters. Capitalization is done by changing the first
+character of each word to upper case.
\end{funcdesc}