Skip to content

Instantly share code, notes, and snippets.

@taboularasa
Created March 10, 2009 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taboularasa/77137 to your computer and use it in GitHub Desktop.
Save taboularasa/77137 to your computer and use it in GitHub Desktop.
take out spaces inside of a string
>>> import re
>>> myString = "apple+ monkey+ bird+ cat+"
>>> myString = re.sub("\s+", "", myString)
>>> myString = myString.rstrip('+')
>>> print myString
apple+monkey+bird+cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment