text = """the numberr offf
theeee beast is 666 ..."""
pattern = '(.)\\1{2,}'
repl = '\\1\\1'
re.sub(pattern, repl, text, flags=re.DOTALL)
Python: how to cut off sequences of more than 2 equal characters in a string