2017-10-12

Python - Replace three consecutive dot-space strings (. . . ) with triple dot (...)

import re
str = "This is one  . . .  . . This is two. And other."
print re.sub( r'((\. )\2{2,2})', '...', str)

No comments:

Post a Comment