fork download
  1. import re
  2. text=' esto .es 10 . er - 12 .23 with [ and.Other ] here is more ; puntuation'
  3. print('text0=',text)
  4. text1 = re.sub(r'(\s+)([;:\.\-])', r'\2', text)
  5. text2 = re.sub(r'\s+\.', '\.', text)
  6. text3 = re.sub(r'\s+\.', r'\.', text)
  7. text4 = re.sub(r'\s+\.', r'\\.', text)
  8. print('text1=',text1)
  9. print('text2=',text2)
  10. print('text3=',text3)
  11. print('text4=',text4)
Success #stdin #stdout 0.02s 27744KB
stdin
Standard input is empty
stdout
text0=  esto  .es  10  . er - 12 .23 with [  and.Other ] here is more ; puntuation
text1=  esto.es  10. er- 12.23 with [  and.Other ] here is more; puntuation
text2=  esto\.es  10\. er - 12\.23 with [  and.Other ] here is more ; puntuation
text3=  esto\.es  10\. er - 12\.23 with [  and.Other ] here is more ; puntuation
text4=  esto\.es  10\. er - 12\.23 with [  and.Other ] here is more ; puntuation