Impossible lookbehind with a backreference,"print(re.sub('(.)(?<=\\1)', '(\\g<0>)', test))"