remove special characters from string javascript

55

remove special characters from string javascript -

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

//if you are using non english like arabic and other language
var outString = sourceString.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');

js remove special characters -

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

Comments

Submit
0 Comments