Microsoft interview question

filtering out special characters in the string