Skip to content

Instantly share code, notes, and snippets.

@maplambda
Created September 26, 2012 09:15
Show Gist options
  • Save maplambda/3786956 to your computer and use it in GitHub Desktop.
Save maplambda/3786956 to your computer and use it in GitHub Desktop.
clean string
import string
letters = frozenset("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789_")
def clean(seq): return filter(lambda x: x in letters, seq)
if __name__ == '__main__':
print clean("test!!!!")
print clean("1__^^^***test!!!!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment