Created
September 10, 2021 09:27
-
-
Save joshstovall/44284adc49ac6dedd6be87d450df7773 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function cleanTweet(e){ | |
return e.text | |
.replace(/\n|\r/g, "") | |
.replace(/(?:https?|ftp):\/\/[\n\S]+/g, '') // remove URLs | |
.replace(/\@[^\s]*/g, "") // remove @ mentions | |
.replace(/\$[^\s]*/g, "") // remove $ cashtags | |
.replace(/\#[^\s]*/g, "") // remove # hashtags | |
.replace('RT', '') // replace RT in retweet tweets | |
.replace('NEW', '') | |
.replace('// // ', '') | |
.replace('- ', '') | |
.trim() // remove extra whitespace | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment