I have a string and I’m trying to remove all characters that are not alphanumeric nor in this set
'''!$%*()_-=+\/.,><:;'"?|'''.
I know this removes all non alphanumeric characters but how can I do better?
re.sub(r'\W+','',line)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A Python 2.x non-regex solution:
The string to filter is
s. (This probably isn’t the fastest solution for long strings.)