mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
gh-99308: Clarify re docs for byte pattern group names (#99311)
This commit is contained in:
parent
b9aa14a484
commit
dbc1e696eb
1 changed files with 9 additions and 7 deletions
|
|
@ -395,9 +395,9 @@ The special characters are:
|
||||||
``(?P<name>...)``
|
``(?P<name>...)``
|
||||||
Similar to regular parentheses, but the substring matched by the group is
|
Similar to regular parentheses, but the substring matched by the group is
|
||||||
accessible via the symbolic group name *name*. Group names must be valid
|
accessible via the symbolic group name *name*. Group names must be valid
|
||||||
Python identifiers, and in bytes patterns they must contain only characters
|
Python identifiers, and in :class:`bytes` patterns they can only contain
|
||||||
in the ASCII range. Each group name must be defined only once within a
|
bytes in the ASCII range. Each group name must be defined only once within
|
||||||
regular expression. A symbolic group is also a numbered group, just as if
|
a regular expression. A symbolic group is also a numbered group, just as if
|
||||||
the group were not named.
|
the group were not named.
|
||||||
|
|
||||||
Named groups can be referenced in three contexts. If the pattern is
|
Named groups can be referenced in three contexts. If the pattern is
|
||||||
|
|
@ -419,8 +419,8 @@ The special characters are:
|
||||||
+---------------------------------------+----------------------------------+
|
+---------------------------------------+----------------------------------+
|
||||||
|
|
||||||
.. versionchanged:: 3.12
|
.. versionchanged:: 3.12
|
||||||
In bytes patterns group names must contain only characters in
|
In :class:`bytes` patterns, group *name* can only contain bytes
|
||||||
the ASCII range.
|
in the ASCII range (``b'\x00'``-``b'\x7f'``).
|
||||||
|
|
||||||
.. index:: single: (?P=; in regular expressions
|
.. index:: single: (?P=; in regular expressions
|
||||||
|
|
||||||
|
|
@ -496,6 +496,8 @@ The special characters are:
|
||||||
|
|
||||||
.. versionchanged:: 3.12
|
.. versionchanged:: 3.12
|
||||||
Group *id* can only contain ASCII digits.
|
Group *id* can only contain ASCII digits.
|
||||||
|
In :class:`bytes` patterns, group *name* can only contain bytes
|
||||||
|
in the ASCII range (``b'\x00'``-``b'\x7f'``).
|
||||||
|
|
||||||
|
|
||||||
The special sequences consist of ``'\'`` and a character from the list below.
|
The special sequences consist of ``'\'`` and a character from the list below.
|
||||||
|
|
@ -1018,8 +1020,8 @@ Functions
|
||||||
|
|
||||||
.. versionchanged:: 3.12
|
.. versionchanged:: 3.12
|
||||||
Group *id* can only contain ASCII digits.
|
Group *id* can only contain ASCII digits.
|
||||||
In bytes replacement strings group names must contain only characters
|
In :class:`bytes` replacement strings, group *name* can only contain bytes
|
||||||
in the ASCII range.
|
in the ASCII range (``b'\x00'``-``b'\x7f'``).
|
||||||
|
|
||||||
|
|
||||||
.. function:: subn(pattern, repl, string, count=0, flags=0)
|
.. function:: subn(pattern, repl, string, count=0, flags=0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue