import re s = "string. With. Punctuation?" s = re.sub(r'[^\w\s]','',s) # \w matches any word character (equivalent to [a-zA-Z0-9_]) # \s matches any whitespace character (equivalent to [\r\n\t\f\v ])
import re s = "string. With. Punctuation?" s = re.sub(r'[^\w\s]','',s) # \w matches any word character (equivalent to [a-zA-Z0-9_]) # \s matches any whitespace character (equivalent to [\r\n\t\f\v ])