summaryrefslogtreecommitdiffstats
path: root/Doc/library/re.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-02-09 22:08:17 (GMT)
committerGitHub <noreply@github.com>2018-02-09 22:08:17 (GMT)
commita445feb72902e4a3c5ae712f0c289309e1580d52 (patch)
tree5a4bbd53ad0fa579f9672370d469f6da000647ff /Doc/library/re.rst
parent2411292ba8155327125d8a1da8a4c9fa003d5909 (diff)
downloadcpython-a445feb72902e4a3c5ae712f0c289309e1580d52.zip
cpython-a445feb72902e4a3c5ae712f0c289309e1580d52.tar.gz
cpython-a445feb72902e4a3c5ae712f0c289309e1580d52.tar.bz2
bpo-30688: Support \N{name} escapes in re patterns. (GH-5588)
Co-authored-by: Jonathan Eunice <jonathan.eunice@gmail.com>
Diffstat (limited to 'Doc/library/re.rst')
-rw-r--r--Doc/library/re.rst9
1 files changed, 6 insertions, 3 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst
index 83ebe7d..475a8d2 100644
--- a/Doc/library/re.rst
+++ b/Doc/library/re.rst
@@ -468,13 +468,13 @@ Most of the standard escapes supported by Python string literals are also
accepted by the regular expression parser::
\a \b \f \n
- \r \t \u \U
- \v \x \\
+ \N \r \t \u
+ \U \v \x \\
(Note that ``\b`` is used to represent word boundaries, and means "backspace"
only inside character classes.)
-``'\u'`` and ``'\U'`` escape sequences are only recognized in Unicode
+``'\u'``, ``'\U'``, and ``'\N'`` escape sequences are only recognized in Unicode
patterns. In bytes patterns they are errors.
Octal escapes are included in a limited form. If the first digit is a 0, or if
@@ -488,6 +488,9 @@ three digits in length.
.. versionchanged:: 3.6
Unknown escapes consisting of ``'\'`` and an ASCII letter now are errors.
+.. versionchanged:: 3.8
+ The ``'\N{name}'`` escape sequence has been added. As in string literals,
+ it expands to the named Unicode character (e.g. ``'\N{EM DASH}'``).
.. seealso::