diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-02-09 22:08:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-09 22:08:17 (GMT) |
commit | a445feb72902e4a3c5ae712f0c289309e1580d52 (patch) | |
tree | 5a4bbd53ad0fa579f9672370d469f6da000647ff /Doc | |
parent | 2411292ba8155327125d8a1da8a4c9fa003d5909 (diff) | |
download | cpython-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')
-rw-r--r-- | Doc/library/re.rst | 9 | ||||
-rw-r--r-- | Doc/whatsnew/3.8.rst | 2 |
2 files changed, 8 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:: diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index 60f54a0..4181981 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -75,6 +75,8 @@ New Features Other Language Changes ====================== +* Added support of ``\N{name}`` escapes in :mod:`regular expressions <re>`. + (Contributed by Jonathan Eunice and Serhiy Storchaka in :issue:`30688`.) New Modules |