Regular Expression: Any character that is NOT a letter or number
Solution 1:
To match anything other than letter or number you could try this:
[^a-zA-Z0-9]
And to replace:
var str = 'dfj,dsf7lfsd .sdklfj';
str = str.replace(/[^A-Za-z0-9]/g, ' ');
Solution 2:
This regular expression matches anything that isn't a letter, digit, or an underscore (_
) character.
\W
For example in JavaScript:
"(,,@,£,() asdf 345345".replace(/\W/g, ' '); // Output: " asdf 345345"