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 ])
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter