rewrite re.sub function

too slow for \b\b replacements