summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-02-25 15:58:30 (GMT)
committerGitHub <noreply@github.com>2019-02-25 15:58:30 (GMT)
commita180b007d96fe68b32f11dec720fbd0cd5b6758a (patch)
treeff75b75fe3cc59732892c647a612aee5328032bf
parent6a44f6eef3d0958d88882347190b3e2d1222c2e9 (diff)
downloadcpython-a180b007d96fe68b32f11dec720fbd0cd5b6758a.zip
cpython-a180b007d96fe68b32f11dec720fbd0cd5b6758a.tar.gz
cpython-a180b007d96fe68b32f11dec720fbd0cd5b6758a.tar.bz2
bpo-28450: Fix and improve the documentation for unknown escapes in RE. (GH-11920)
-rw-r--r--Doc/library/re.rst7
1 files changed, 5 insertions, 2 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index b512830..4ac5dee 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -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
@@ -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::