Last active
December 28, 2020 10:29
-
-
Save lppier/52daf623f8caae6357608130c168078e to your computer and use it in GitHub Desktop.
regex python cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove URLs | |
text_clean = [re.sub(r'http\S+', '', t) for t in text] | |
# Remove new lines \n | |
text_clean= [t.strip().replace('\n', ' ') for t in text_clean] | |
# Remove emails | |
text_clean = [re.sub(r'[\w\.-]+@[\w\.-]+', '', t) for t in text_clean] | |
# Remove single quotes | |
data = [re.sub("\'", "", sent) for sent in data] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment