bpo-28450: Fix and improve the documentation for unknown escapes in R… · python/cpython@a180b00 (original) (raw)

`@@ -573,7 +573,8 @@ accepted by the regular expression parser::

`

573

573

`only inside character classes.)

`

574

574

``

575

575

``` '\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.

`

`577`

`578`

``

`578`

`579`

`Octal escapes are included in a limited form. If the first digit is a 0, or if

`

`579`

`580`

`there are three octal digits, it is considered an octal escape. Otherwise, it is

`

`@@ -850,7 +851,9 @@ form.

`

`850`

`851`

` *string* is returned unchanged. *repl* can be a string or a function; if it is

`

`851`

`852`

```  a string, any backslash escapes in it are processed. That is, ``\n`` is

852

853

``` 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

`

854

857

``` as \6, are replaced with the substring matched by group 6 in the pattern.

```

855

858

` For example::

`

856

859

``