I want to filter out the special characters from a string, but I also want to preserve some of them (for example, I want to preserve apostrophe, &, -, %)
This code will keep the apostrophe, but how can I add the other symbols I want to keep?
msg = 'Hi! I'm Mike, I like M&M. How are you?'
pattern = re.compile("[^\w']")
pattern.sub ('', msg)
>>Output Desired: "Hi I'm Mike I like M&M How are you"