10000 [3.11] gh-101699: Explain using Match.expand with \g<0> (GH-101701) by miss-islington · Pull Request #115584 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.11] gh-101699: Explain using Match.expand with \g<0> (GH-101701) #115584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

(cherry picked from commit d2d7808)

Co-authored-by: Stevoisiak <S.Vascellaro@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
  • Loading branch information
2 people authored and miss-islington committed Feb 17, 2024
commit b66d46f0ca3a9399ee4b8bea75c3b5ab3110b35a
3 changes: 2 additions & 1 deletion Doc/library/re.rst
6A46
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,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.
Expand Down
0