Skip to content

Instantly share code, notes, and snippets.

@tpeng
Last active December 19, 2015 05:59
Show Gist options
  • Save tpeng/5907865 to your computer and use it in GitHub Desktop.
Save tpeng/5907865 to your computer and use it in GitHub Desktop.
import re
_SPACING_RE = re.compile(ur'\n[\s]+', re.DOTALL)
text = "\r\n Grand Hotel, Malahide, County Dublin, Ireland\r\n Tel. +353 1 845 0000 Fax +353 1 816 8225\r\n Email: [email protected]"
print _SPACING_RE.sub(u'', text)
print _SPACING_RE.sub(u'\n', text)
# output on my machine:
#Email: [email protected] +353 1 816 8225eland
#Grand Hotel, Malahide, County Dublin, Ireland
#Tel. +353 1 845 0000 Fax +353 1 816 8225
#Email: [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment