Skip to content

Instantly share code, notes, and snippets.

@AyishaR
Created February 19, 2021 07:05
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 AyishaR/b698f6755a89a5dca9c14d566a36396c to your computer and use it in GitHub Desktop.
Save AyishaR/b698f6755a89a5dca9c14d566a36396c to your computer and use it in GitHub Desktop.
# Remove html tags
def removeHTML(sentence):
regex = re.compile('<.*?>')
return re.sub(regex, ' ', sentence)
# Remove URLs
def removeURL(sentence):
regex = re.compile('http[s]?://\S+')
return re.sub(regex, ' ', sentence)
# remove numbers, punctuation and any special characters (keep only alphabets)
def onlyAlphabets(sentence):
regex = re.compile('[^a-zA-Z]')
return re.sub(regex, ' ', sentence)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment