Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import re
  3. line = input()
  4.  
  5. extra_spaces = re.compile(r'(?<= ) +')
  6. need_space = re.compile(r'([\.\?\!])(?![ ])')
  7. eol_space = re.compile(r'(?<=[\.\?\!]) +$')
  8. lower = re.compile(r'((?<=[A-Z])[a-zA-Z]*[a-z][a-zA-Z]*|(?<=[a-z])[a-zA-Z]+)')
  9.  
  10.  
  11. while(line != ""):
  12.   line = extra_spaces.sub("",line)
  13.   line = need_space.sub(r'\1 ', line)
  14.   line = eol_space.sub("",line)
  15.   line = lower.sub(lambda x: x.group(0).lower(),line)
  16.   print (line)
  17.   line = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement