Posted By

myoffe on 03/10/11


Tagged

whitespace String


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

doryexmachina


normalize whitespace


 / Published in: Python
 

  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  

You need to login to post a comment.