new_string = re.sub(matcher, '\\1', old_string)
while new_string != old_string:
    old_string = new_string
new_string = re.sub(matcher, '\\1', new_string)
return new_string
Python grouped backreferences