remove punctuation from string python module code example
Example 1: remove punctuation from string python
#with re
import re
s = "string. With. Punctuation?"
s = re.sub(r'[^\w\s]','',s)
#without re
s = "string. With. Punctuation?"
s.translate(str.maketrans('', '', string.punctuation))
Example 2: python3 strip punctuation from string
import string
#make translator object
translator=str.maketrans('','',string.punctuation)
string_name=string_name.translate(translator)