Suppose I have this:
My---sun--is------very-big---.
I want to replace all multiple hyphens with just one hyphen.
import re astr='My---sun--is------very-big---.' print(re.sub('-+','-',astr)) # My-sun-is-very-big-.
2.1m questions
2.1m answers
60 comments
57.0k users