Off topic,
For numbered capture groups:
#/usr/bin/env python
import re
re.sub(
pattern=r'(\d)(\w+)',
repl='word: \\2, digit: \\1',
string='1asdf'
)
word: asdf, digit: 1
Python uses literal backslash, plus one-based-index to do numbered capture group replacements, as shown in this example. So \1, entered as '\\1', references the first capture group (\d), and \2 the second captured group.