Skip to content

Instantly share code, notes, and snippets.

@glesica
Created June 8, 2012 19:48
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 glesica/2897794 to your computer and use it in GitHub Desktop.
Save glesica/2897794 to your computer and use it in GitHub Desktop.
>>> a = re.compile(r'^[0-9_]+|\W|[_]+$')
>>> a.findall('__hello world')
['__', ' ']
>>> a.sub('', '__username@gmail.com_table name hello')
'usernamegmailcom_tablenamehello'
>>> a.sub('', 'a')
'a'
>>> a.sub('', '_')
''
>>> a.sub('', '0')
''
>>> b = re.compile(r'\W')
>>> b.sub('', '__username@gmail.com_table name hello')
'__usernamegmailcom_tablenamehello'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment