summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2001-08-28 12:50:03 (GMT)
committerEric S. Raymond <esr@thyrsus.com>2001-08-28 12:50:03 (GMT)
commit46ccd1dae562baa70c16d13e5131e651d3bb5f21 (patch)
tree0647f976cf3e54ad18fd9f4ab5331e42a0abebab /Doc/lib
parent8c64a54f7562797f47c45b69f557903ef3ab4f4f (diff)
downloadcpython-46ccd1dae562baa70c16d13e5131e651d3bb5f21.zip
cpython-46ccd1dae562baa70c16d13e5131e651d3bb5f21.tar.gz
cpython-46ccd1dae562baa70c16d13e5131e651d3bb5f21.tar.bz2
Plant a mention in the description of backreferences of the fact that
while \0 doesn't do what one might expect, \g<0> does.
Diffstat (limited to 'Doc/lib')
-rw-r--r--Doc/lib/libre.tex6
1 files changed, 5 insertions, 1 deletions
diff --git a/Doc/lib/libre.tex b/Doc/lib/libre.tex
index aa18814..8531732 100644
--- a/Doc/lib/libre.tex
+++ b/Doc/lib/libre.tex
@@ -297,6 +297,8 @@ the space after the group). This special sequence can only be used to
match one of the first 99 groups. If the first digit of \var{number}
is 0, or \var{number} is 3 octal digits long, it will not be interpreted
as a group match, but as the character with octal value \var{number}.
+(There is a group 0, which is the entire matched pattern, but it can't
+be referenced with \regexp{\e 0}; instead, use \regexp{\e g<0>}.)
Inside the \character{[} and \character{]} of a character class, all numeric
escapes are treated as characters.
@@ -566,7 +568,9 @@ ignored.
\samp{\e g<2>} is therefore equivalent to \samp{\e 2}, but isn't
ambiguous in a replacement such as \samp{\e g<2>0}. \samp{\e 20}
would be interpreted as a reference to group 20, not a reference to
- group 2 followed by the literal character \character{0}.
+ group 2 followed by the literal character \character{0}. The
+ backreference \samp{\e g<0>} substitutes in the entire substring
+ matched by the RE.
\end{funcdesc}
\begin{funcdesc}{subn}{pattern, repl, string\optional{, count}}