Skip to content

bpo-28450: Fix and improve the documentation for unknown escapes in RE. #11920

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
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
7 changes: 5 additions & 2 deletions Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ accepted by the regular expression parser::
only inside character classes.)

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

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

Expand Down