Commit 15ae75d6 authored by Ricardo Bánffy's avatar Ricardo Bánffy Committed by Serhiy Storchaka

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.
parent 60ec6efd
......@@ -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()
......
......@@ -356,3 +356,4 @@ whatsnew/changelog,,::,default::BytesWarning
whatsnew/changelog,,::,default::DeprecationWarning
library/importlib.metadata,,:main,"EntryPoint(name='wheel', value='wheel.cli:main', group='console_scripts')"
library/importlib.metadata,,`,loading the metadata for packages for the indicated ``context``.
library/re,,`,"`"
Add list of no-longer-escaped chars to re.escape documentation
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment