I have an arbitrary string that comes from a database. I want to place this string as an HTML class name on a web page. I am not sure what characters to expect. How can I remove the spaces and special characters to make it "safe" to be a CSS class name?
After some research, it seems space and these characters need to be remove:
!"#$%&'()*+,./:;<=>?@[\]^`{|}~
What is the best way to remove them?