不包含某些字符:
function zz) {
var str = '1234567890abc[123456789';
var $sz = /[#$@/\\)<>{}[\] ]/gi;//常见的特殊字符不够[]里面继续加
if$sz.teststr)){
console.logstr+'中含有特殊字符');
}else {
console.logstr+'不中含有特殊字符');
}
}
不包含某些字符串:
function zz) {
var str = "1234567890abc[123456789";
var $sz = /^?!666|zzz|abc).)*$/;//字符串按照要求换,加;
if $sz.teststr)) {
console.logstr+'不含有指定字符串!') ;
} else {
console.logstr+'含有指定字符串!') ;
}
}
当然下面不包含字符串可以演变为不包含字符使用,看你喜欢使用。
