How to Remove Special Characters in JavaScript String
Alternatively, to change all characters except numbers and letters, try:
var string="Air!()*@!||#$%&*&Bhurtan";
string = string.replace(/[^a-zA-Z0-9]/g,'');
alert("string : "+string);
string = string.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,'');
var
string = string.replace(/[&\/\\#,+()$~%.'":*?<>{}]/g,'_');
alert("string : "+string);
Alternatively, to change all characters except numbers and letters, try:
var string="Air!()*@!||#$%&*&Bhurtan";
string = string.replace(/[^a-zA-Z0-9]/g,'');
alert("string : "+string);
or
string = string.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,'');
alert("string : "+string);
No comments:
Post a Comment