remove special characters from string python

import re
re.sub('[^A-Za-z0-9]+', '', mystring)

Here is what the above code is Doing:
1. The first argument is the regular expression.
2. The second argument is the replacement string.
3. The third argument is the original string.
4. The ‘[^A-Za-z0-9]+’ is a regular expression that will replace any character that is not a letter or number with an empty string.
5. The ‘+’ means that the character can occur one or more times.
6. The ‘g’ means that all occurrences should be replaced.