I need to replace words like goooooooooooood with good. For this i tried
t.replace(r'(.)\2+',r'\2')
where t is some word like gooooooooooood
but this doesn't work.
What you are looking for is a spell checker. There are multiple ways of doing it but few ways I found useful is
You can use itertools.groupby():
In [53]: strs="goooooooooooood"
In [54]: from itertools import groupby
In [55]: "".join(k*2 if len(list(g))>=2 else k for k,g in groupby(strs))
Out[55]: 'good'
tseems to be a string, that means you're not using regex but regular character replacement here.