benjamincharity
3/29/2016 - 6:00 PM

The caret (^) character is the negation of the set [...], gi say global and case-insensitive (the latter is a bit redundant but I wanted to

The caret (^) character is the negation of the set [...], gi say global and case-insensitive (the latter is a bit redundant but I wanted to mention it) and the safelist in this example is digits, word characters, underscores (\w) and whitespace (\s).

https://stackoverflow.com/questions/4374822/javascript-regexp-remove-all-special-characters

var desired = stringToReplace.replace(/[^\w\s]/gi, '')