How do I replace two or more periods in a string with a unicode ellipsis?
e.g.
Hey. -> Hey. (does not change)
Hey.. -> Hey… (all of these change)
Hey... -> Hey…
Hey.... -> Hey…
Hey..... -> Hey…
This will do it. It uses a regular expression to match two or more dots.
import re
s='Hey.....'
new_string = re.sub(r'[.][.][.]*', '…', s)
print(new_string)