Skip to content

Commit a180b00

Browse files
bpo-28450: Fix and improve the documentation for unknown escapes in RE. (GH-11920)
1 parent 6a44f6e commit a180b00

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Doc/library/re.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,8 @@ accepted by the regular expression parser::
573573
only inside character classes.)
574574

575575
``'\u'``, ``'\U'``, and ``'\N'`` escape sequences are only recognized in Unicode
576-
patterns. In bytes patterns they are errors.
576+
patterns. In bytes patterns they are errors. Unknown escapes of ASCII
577+
letters are reserved for future use and treated as errors.
577578

578579
Octal escapes are included in a limited form. If the first digit is a 0, or if
579580
there are three octal digits, it is considered an octal escape. Otherwise, it is
@@ -850,7 +851,9 @@ form.
850851
*string* is returned unchanged. *repl* can be a string or a function; if it is
851852
a string, any backslash escapes in it are processed. That is, ``\n`` is
852853
converted to a single newline character, ``\r`` is converted to a carriage return, and
853-
so forth. Unknown escapes such as ``\&`` are left alone. Backreferences, such
854+
so forth. Unknown escapes of ASCII letters are reserved for future use and
855+
treated as errors. Other unknown escapes such as ``\&`` are left alone.
856+
Backreferences, such
854857
as ``\6``, are replaced with the substring matched by group 6 in the pattern.
855858
For example::
856859

0 commit comments

Comments
 (0)