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)
var str = 's - 4 string, , - want remove characters 49494 not letters or "numbers"'; var result = str.replace(/[\w_]+/g, ' ');
Comments
Post a Comment