Empty matches in Python’s `re` module
https://blog.narf.ssji.net/2025/04/30/empty-matches-in-pythons-re-module/
Python’s `re.sub` method has a weird, though documented, behaviour.
Replacements for empty-matching patterns such as `/.*/` applied to a non-empty string will lead to two matches. The replacement will therefore be applied twice.
A simple fix is to make sure the pattern is not empty-matching, e.g. `/.+/`.