summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libregsub.tex
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-01-02 01:22:07 (GMT)
committerGuido van Rossum <guido@python.org>1994-01-02 01:22:07 (GMT)
commit5fdeeeae2a12b9956cc84d62eae82f72cabc8664 (patch)
treeac0053479e10099850c8e0d06e31cb3afbf632bb /Doc/lib/libregsub.tex
parent0b0719866e8a32d0a787e73bca9e79df1d1a74f8 (diff)
downloadcpython-5fdeeeae2a12b9956cc84d62eae82f72cabc8664.zip
cpython-5fdeeeae2a12b9956cc84d62eae82f72cabc8664.tar.gz
cpython-5fdeeeae2a12b9956cc84d62eae82f72cabc8664.tar.bz2
Restructured library documentation
Diffstat (limited to 'Doc/lib/libregsub.tex')
-rw-r--r--Doc/lib/libregsub.tex30
1 files changed, 30 insertions, 0 deletions
diff --git a/Doc/lib/libregsub.tex b/Doc/lib/libregsub.tex
new file mode 100644
index 0000000..5747e4f
--- /dev/null
+++ b/Doc/lib/libregsub.tex
@@ -0,0 +1,30 @@
+\section{Standard Module \sectcode{regsub}}
+
+\stmodindex{regsub}
+This module defines a number of functions useful for working with
+regular expressions (see built-in module \code{regex}).
+
+\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,
+the string is returned unchanged. The pattern may be a string or an
+already compiled pattern. The replacement may contain references
+\samp{\e \var{digit}} to subpatterns and escaped backslashes.
+\end{funcdesc}
+
+\begin{funcdesc}{gsub}{pat\, repl\, str}
+Replace all (non-overlapping) occurrences of pattern \var{pat} in
+string \var{str} by replacement \var{repl}. The same rules as for
+\code{sub()} apply. Empty matches for the pattern are replaced only
+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}
+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']}.
+\end{funcdesc}