I want to remove punctuation such as " ", ' ', , , "", '' from my string using regex. The code so far I've written only removes the ones which space between them. How do I remove the empty ones such as '',
#Code
s = "hey how ' ' is the ` ` what are '' you doing `` how is everything"
s = re.sub("' '|` `|" "|""|''|``","",s)
print(s)
My expected outcome:
hey how is the what are you doing how is everything
?after the space to match on it, optionally.re.sub("' ?'|` ?`|" ?""',"",s)newstr = "" for char in mystr: if char not in ('"', ... (put punctuation characters here)): newstr += charpairedquotes with/without whitespace in between ? You can't just match stuff like""without matching all quotes.