标签:ret 检测 特殊字符 判断 过滤 special reg 字符串转换 去掉
// var str1 = str.replace(/[\‘\"\\\/\b\f\n\r\t]/g, ‘‘);// 去掉转义字符
// var str2= str.replace(/[\-\_\,\!\|\~\`\(\)\#\$\%\^\&\*\{\}\:\;\"\L\<\>\?]/g, ‘‘);// 去掉特殊字符
// return str2;
var containSpecial = RegExp(/[(\ )(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=)(\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\‘)(\")(\,)(\.)(\/)(\<)(\>)(\?)(\)]+/);
return ( containSpecial.test(s) ); 判断是否含有
var filterRule= /[^0-9a-zA-Z_]/g;
var judge= filterRule.test(str); //判断传进来的数据是否含有特殊字符。test函数返回匹配结
var rows=JSON.stringify(rows);////将json对象转换成json对符串
var rows=JSON.parse(rows);//将json字符串转换成json对象
标签:ret 检测 特殊字符 判断 过滤 special reg 字符串转换 去掉
原文地址:http://www.cnblogs.com/crystaltu/p/7567776.html