-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
Closed as not planned
Labels
Description
Feature or enhancement
CURRENT STATUS
Python 3.13.1 (tags/v3.13.1:0671451, Dec 3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> p=re.compile(r'a')
p.sub(r'\0-','axa')
'\x00-x\x00-'
p.sub(r'\g<0>-','axa')
'a-xa-'
Reasons for this
The consistency of Python code style is an important reason for its favorable reception. However, as shown in the code demonstrated just now, this is not well achieved in the re
module. \1
and the like are treated as capture groups, but \0
is the only exception, which is unreasonable.