Tim Peters added the comment: Well, some backslash escapes are processed in the "replacement" argument to `.sub()`. If your replacement text contains a substring of the form
\g not immediately followed by < that will raise the exception you're seeing. The parser is expecting to see a "matched group" reference after "\g", like \g<1> \g<name_of_named_group> So it depends on the value of your `new_output`. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27586> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com