Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment: In your case you can just pass 1 as the fourth parameter of re.sub(). ---------- _______________________________________ Python tracker <report at bugs.python.org> <https://bugs.python.org/issue32998> _______________________________________