Skip to content

Instantly share code, notes, and snippets.

@himlohiya
Created June 29, 2018 18:34
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 himlohiya/89c96851ffedf89638abb126ca37e430 to your computer and use it in GitHub Desktop.
Save himlohiya/89c96851ffedf89638abb126ca37e430 to your computer and use it in GitHub Desktop.
def remove_special_characters(text, remove_digits=False):
pattern = r'[^a-zA-z0-9\s]' if not remove_digits else r'[^a-zA-z\s]'
text = re.sub(pattern, '', text)
return text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment