programming-examples/python/Regular_Expression/Replace maximum 2 occurrences of space, comma, or dot with a colon.py
2019-11-15 12:59:38 +01:00

3 lines
95 B
Python

import re
text = 'Python Exercises, PHP exercises.'
print(re.sub("[ ,.]", ":", text, 2))