javascript - Remove all characters that are not letters or numbers in a String -


how can remove characters not letters or 'numbers'??

i have string:

var string = 'this - 4 string, , - want remove characters 49494 not letters or "numbers"'; 

and want transform this:

var string = 'this 4 string , want remove characters 49494 not letters or numbers' 

this possible?

thanks!!

you can use regex this:

[\w_]+ 

the idea match \w non word character (those characters not a-z, a-z, 0-9 , _) , add explicitly _ (since underscore considered word character)

working demo

var str = 's - 4 string, , - want remove characters 49494 not letters or "numbers"';      var result = str.replace(/[\w_]+/g, ' '); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -