This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Incomplete documentation for re.sub
Type: Stage: resolved
Components: Regular Expressions Versions: Python 3.8, Python 3.7
Status: closed Resolution: duplicate
Dependencies: Superseder: Misleading/inaccurate documentation about unknown escape sequences in regular expressions
View: 28450
Assigned To: Nosy List: Windson Yang, ezio.melotti, mrabarnett, pbugnion, serhiy.storchaka
Priority: normal Keywords:

Created on 2019-01-29 08:06 by pbugnion, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg334504 - (view) Author: Pascal Bugnion (pbugnion) Date: 2019-01-29 08:06
The documentation for `re.sub` states that "Unknown escapes such as ``\&`` are left alone.". This is only true for escapes which are not ascii characters, as far as I can tell (c.f. source on

Would there be value in amending that documentation to either remove that sentence or to clarify it? If so, I'm happy to submit a PR on GitHub.
msg334642 - (view) Author: Windson Yang (Windson Yang) * Date: 2019-02-01 01:46
I wonder if possible that c not in ASCIILETTERS when we get KeyError?

    if c in ASCIILETTERS:
        raise s.error('bad escape %s' % this, len(this))
msg335543 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2019-02-14 16:47
This is a duplicate of issue28450.
Date User Action Args
2022-04-11 14:59:10adminsetgithub: 80027
2019-02-14 16:47:40serhiy.storchakasetstatus: open -> closed

superseder: Misleading/inaccurate documentation about unknown escape sequences in regular expressions

nosy: + serhiy.storchaka
messages: + msg335543
resolution: duplicate
stage: resolved
2019-02-01 01:46:34Windson Yangsetnosy: + Windson Yang
messages: + msg334642
2019-01-29 08:06:08pbugnioncreate