Skip to content

Instantly share code, notes, and snippets.

@cadrev
Created July 7, 2015 02:37
Show Gist options
  • Save cadrev/d26a87a12daac93e82ff to your computer and use it in GitHub Desktop.
Save cadrev/d26a87a12daac93e82ff to your computer and use it in GitHub Desktop.
Python Regex Test
'''
Removes punctuations and non Alpha-numeric characters, removes trailing spaces
and prints the string in lowercase
'''
import re
text = " sample_ @$@string %*hi^*&there "
clean_text = re.sub(r'[^A-Za-z0-9\s]+','',text).lower().strip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment