javascript regular expression remove non alphanumeric code example
Example 1: remove non alphanumeric characters javascript
input.replace(/\W/g, '') //doesnt include underscores
input.replace(/[^0-9a-z]/gi, '') //removes underscores too
Example 2: javascript regular expression for alphanumeric
/^[a-z0-9]+$/i
^ Start of string
[a-z0-9] a or b or c or ... z or 0 or 1 or ... 9
+ one or more times (change to * to allow empty string)
$ end of string
/i case-insensitive