Skip to content

Instantly share code, notes, and snippets.

@anb
Created April 15, 2011 09:21
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 anb/921448 to your computer and use it in GitHub Desktop.
Save anb/921448 to your computer and use it in GitHub Desktop.
In [1]: import re
In [2]: nonascii = re.compile('[^a-zA-Z]')
...: formatkey = lambda s: nonascii.sub('', s.lower().strip())
In [3]: test_string = "fdasafsdB324234_()324sdafasd[]$$$"
In [4]: formatkey(test_string)
Out[4]: 'fdasafsdbsdafasd'
In [5]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment