Replacing all non-alphanumeric characters with empty strings

Alex Gomes picture Alex Gomes · Nov 26, 2009 · Viewed 243.8k times · Source

I tried using this but didn't work-

return value.replaceAll("/[^A-Za-z0-9 ]/", "");

Answer

Mirek Pluta picture Mirek Pluta · Nov 26, 2009

Use [^A-Za-z0-9].

Note: removed the space since that is not typically considered alphanumeric.