summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStevoisiak <S.Vascellaro@gmail.com>2024-02-17 08:33:28 (GMT)
committerGitHub <noreply@github.com>2024-02-17 08:33:28 (GMT)
commitd2d78088530433f475d9304104bbc0dac2536edd (patch)
treeedc7e3e849e82f9e7c18551e76041b4612a3ebf1
parent73e8637002639e565938d3f205bf46e7f1dbd6a8 (diff)
downloadcpython-d2d78088530433f475d9304104bbc0dac2536edd.zip
cpython-d2d78088530433f475d9304104bbc0dac2536edd.tar.gz
cpython-d2d78088530433f475d9304104bbc0dac2536edd.tar.bz2
gh-101699: Explain using Match.expand with \g<0> (GH-101701)
Update documentation for re library to explain that a backreference `\g<0>` is expanded to the entire string when using Match.expand(). Note that numeric backreferences to group 0 (`\0`) are not supported. Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r--Doc/library/re.rst3
1 files changed, 2 insertions, 1 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index a5bd5c7..0336121 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -1344,7 +1344,8 @@ when there is no match, you can test whether there was a match with a simple
Escapes such as ``\n`` are converted to the appropriate characters,
and numeric backreferences (``\1``, ``\2``) and named backreferences
(``\g<1>``, ``\g<name>``) are replaced by the contents of the
- corresponding group.
+ corresponding group. The backreference ``\g<0>`` will be
+ replaced by the entire match.
.. versionchanged:: 3.5
Unmatched groups are replaced with an empty string.