10000 [3.11] gh-101699: Explain using Match.expand with \g<0> (GH-101701) (… · python/cpython@5b6e358 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5b6e358

Browse files
miss-islingtonStevoisiakserhiy-storchaka
authored
[3.11] gh-101699: Explain using Match.expand with \g<0> (GH-101701) (GH-115584)
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. (cherry picked from commit d2d7808) Co-authored-by: Stevoisiak <S.Vascellaro@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 4077f14 commit 5b6e358

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
@@ -1336,7 +1336,8 @@ when there is no match, you can test whether there was a match with a simple
13361336
Escapes such as ``\n`` are converted to the appropriate characters,
13371337
and numeric backreferences (``\1``, ``\2``) and named backreferences
13381338
(``\g<1>``, ``\g<name>``) are replaced by the contents of the
1339-
corresponding group.
1339+
corresponding group. The backreference ``\g<0>`` will be
1340+
replaced by the entire match.
13401341

13411342
.. versionchanged:: 3.5
13421343
Unmatched groups are replaced with an empty string.

0 commit comments

Comments
 (0)
0