首页 > 代码库 > js 过滤字符 和检测 特殊字符

js 过滤字符 和检测 特殊字符

var containSpecial = RegExp(/[(\ )(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=)(\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\‘)(\")(\,)(\.)(\/)(\<)(\>)(\?)(\)]+/);
return ( containSpecial.test(s) ); 判断是否含yon
var filterRule= /[^0-9a-zA-Z_]/g;
var judge= filterRule.test(str); //判断传进来的数据是否含有特殊字符。test函数返回匹配结

js 过滤字符 和检测 特殊字符