normalize whitespace


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def normalize_whitespace(str):
  2. import re
  3. str = str.strip()
  4. str = re.sub(r'\s+', ' ', str)
  5. return str

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.