Skip to content

Commit d2d7808

Browse files
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 <[email protected]>
1 parent 73e8637 commit d2d7808

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Doc/library/re.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1344,7 +1344,8 @@ when there is no match, you can test whether there was a match with a simple
13441344
Escapes such as ``\n`` are converted to the appropriate characters,
13451345
and numeric backreferences (``\1``, ``\2``) and named backreferences
13461346
(``\g<1>``, ``\g<name>``) are replaced by the contents of the
1347-
corresponding group.
1347+
corresponding group. The backreference ``\g<0>`` will be
1348+
replaced by the entire match.
13481349

13491350
.. versionchanged:: 3.5
13501351
Unmatched groups are replaced with an empty string.

0 commit comments

Comments
 (0)