Last active
October 9, 2015 00:50
-
-
Save yamaguchiyuto/31aa151c475cf52884b4 to your computer and use it in GitHub Desktop.
Removing URLs and usernames in tweets
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
import re | |
def remove_usernames_and_urls(text): | |
username_removed_text = re.sub('@\w+', '', text) # remove usernames | |
return re.sub('(https?|ftp)(:\/\/[-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)', '', username_removed_text) # remove urls |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment