import re # only remove special charactors but not white spaces re.sub('[^A-Za-z0-9]+ ', '', mystring) # remove special charactors and white spaces as well re.sub('[^A-Za-z0-9]+', '', mystring)