/***
- 去掉字符串中的特殊字符
*/
var excludeSpecial = function(s) {
// 去掉转义字符
s = s.replace(/[’"\/\b\f\n\r\t]/g, ‘’);
// 去掉特殊字符
s = s.replace(/[@#$%^&*{}:"\L<>?
]/);
return s;
};
function main(){
var s = “He is\tcalled ‘Johnny’”;;
console.log(s);
console.log(excludeSpecial(s));
console.log(s);
};
main();
来源:CSDN
作者:_必应
链接:https://blog.csdn.net/jbguo/article/details/104695164