Created
July 13, 2020 15:59
-
-
Save lisanka93/bbcc52403ba394daf3af2996ec0216a5 to your computer and use it in GitHub Desktop.
regular expressions to remove punctuation
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
import re | |
#letters only | |
raw_text = "this is a test. To demonstrate 2 regex expressions!!" | |
letters_only_text = re.sub("[^a-zA-Z]", " ", raw_text) | |
#keep numbers | |
letnum_text = re.sub("[^a-zA-Z0-9\s]+", " ",raw_text ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment