I\'m trying to find characters that are repeated 3 times or more, for example I want to take the following strings:
(\'aaa\', \'buuuuut\',
\'aaa\'
\'buuuuut\'
Look at this:
>>> mystr = 'buuuuuttttt' >>> re.sub(r'(.)\1{2,}', r'\1', mystr) 'but' >>> mystr = 'buttt' >>> re.sub(r'(.)\1{2,}', r'\1', mystr) 'but' >>>