Not going to insist, but why not `re.sub(before, after, s)`?