[issue47023] re.sub shows key error on regex escape chars provided in repl param

Raymond Hettinger report at bugs.python.org
Thu Mar 17 16:36:37 EDT 2022


Raymond Hettinger <raymond.hettinger at gmail.com> added the comment:

There seem to be a number of escaping problems in the OP's example.

Is this what was intended?

>>> re.sub(r"\{(\w+)\}", r"\1", "Hello! {user}")
'Hello! user'

----------
nosy: +rhettinger
status: pending -> open

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47023>
_______________________________________


More information about the Python-bugs-list mailing list