fork download
  1. import re
  2. strings = [
  3. "python...is...fun...",
  4. "python...is...fun",
  5. "python...is...fun??"
  6. ]
  7.  
  8. for s in strings:
  9. new_text = re.sub(r"(?:\.{2,}|(?<!\.))$", ".", s)
  10. print(new_text)
Success #stdin #stdout 0.02s 9676KB
stdin
Standard input is empty
stdout
python...is...fun.
python...is...fun.
python...is...fun??.