diff options
author | Ricardo Bánffy <rbanffy@gmail.com> | 2019-10-07 20:54:35 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-10-07 20:54:35 (GMT) |
commit | 15ae75d660befe643ed42eb2707a557cea97256c (patch) | |
tree | 5d21a89bb78b6fd23e888a6dafd0a4204555b241 /Doc/library/re.rst | |
parent | 60ec6efd96d95476fe5e38c491491add04f026e5 (diff) | |
download | cpython-15ae75d660befe643ed42eb2707a557cea97256c.zip cpython-15ae75d660befe643ed42eb2707a557cea97256c.tar.gz cpython-15ae75d660befe643ed42eb2707a557cea97256c.tar.bz2 |
bpo-38294: Add list of no-longer-escaped chars to re.escape documentation. (GH-16442)
Prior to 3.7, re.escape escaped many characters that don't have
special meaning in Python, but that use to require escaping in other
tools and languages. This commit aims to make it clear which characters
were, but are no longer escaped.
Diffstat (limited to 'Doc/library/re.rst')
-rw-r--r-- | Doc/library/re.rst | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/re.rst b/Doc/library/re.rst index df29c4d..7c950bf 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -931,8 +931,8 @@ form. This is useful if you want to match an arbitrary literal string that may have regular expression metacharacters in it. For example:: - >>> print(re.escape('python.exe')) - python\.exe + >>> print(re.escape('http://www.python.org')) + http://www\.python\.org >>> legal_chars = string.ascii_lowercase + string.digits + "!#$%&'*+-.^_`|~:" >>> print('[%s]+' % re.escape(legal_chars)) @@ -955,7 +955,9 @@ form. .. versionchanged:: 3.7 Only characters that can have special meaning in a regular expression - are escaped. + are escaped. As a result, ``'!'``, ``'"'``, ``'%'``, ``"'"``, ``','``, + ``'/'``, ``':'``, ``';'``, ``'<'``, ``'='``, ``'>'``, ``'@'``, and + ``"`"`` are no longer escaped. .. function:: purge() |