Javascript – Regular Expression: Any character that is NOT a letter or number

javascriptregex

I'm trying to figure out the regular expression that will match any character that is not a letter or a number. So characters such as (,,@,£,() etc …

Once found I want to replace it with a blank space.

Any advice.

Best Answer

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, ' ');