[3.7] bpo-28450: Fix and improve the documentation for unknown escape… · python/cpython@95fc8e6 (original) (raw)
`@@ -570,7 +570,8 @@ accepted by the regular expression parser::
`
570
570
`only inside character classes.)
`
571
571
``
572
572
``` '\u'
and '\U'
escape sequences are only recognized in Unicode
`573`
``
`-
patterns. In bytes patterns they are errors.
`
``
`573`
`+
patterns. In bytes patterns they are errors. Unknown escapes of ASCII
`
``
`574`
`+
letters are reserved for future use and treated as errors.
`
`574`
`575`
``
`575`
`576`
`Octal escapes are included in a limited form. If the first digit is a 0, or if
`
`576`
`577`
`there are three octal digits, it is considered an octal escape. Otherwise, it is
`
`@@ -844,7 +845,9 @@ form.
`
`844`
`845`
` *string* is returned unchanged. *repl* can be a string or a function; if it is
`
`845`
`846`
``` a string, any backslash escapes in it are processed. That is, ``\n`` is
846
847
``` converted to a single newline character, \r
is converted to a carriage return, and
`847`
``
``` -
so forth. Unknown escapes such as ``\&`` are left alone. Backreferences, such
``
848
`+
so forth. Unknown escapes of ASCII letters are reserved for future use and
`
``
849
treated as errors. Other unknown escapes such as ``\&`` are left alone.
``
850
`+
Backreferences, such
`
848
851
``` as \6
, are replaced with the substring matched by group 6 in the pattern.
```
849
852
` For example::
`
850
853
``