js常用的正则
1.5位整数带两位小数
/^\d{0,5}(\.\d{0,2})?$/g
/^\d{0,5}(\.\d{0,2})?$/g
2.邮箱
/^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g
3.不带小数的
/^[0-9]*$/
4.数字、英文、特殊字符
/^[\w\+=_!@#%&*-]+$/
5.不含特殊字符
/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/
6.数字大小写字母
/^[0-9a-zA-Z]+$/
7.只能输入中文
/^[\u0391-\uFFE5]+$/
8.中文,英文,数字
/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/
res(a,b,str){ //数字加英文 let re = `\^\\w{${a},${b}}\$` let reg = new RegExp(re); let status = !reg.test(str) return status }, res2(a,b,str){ //中英文字符 let re = `\^[\u4e00-\u9fa5_a-zA-Z]{${a},${b}}\$` let reg = new RegExp(re); let status = !reg.test(str) return status }, res3(a,b,str){ //中文字符 let re = `\^[\u4e00-\u9fa5]{${a},${b}}\$` let reg = new RegExp(re); let status = !reg.test(str) return status }, res4(a,b,str){ //数字 let re = `\^[0-9]{${a},${b}}\$` let reg = new RegExp(re); let status = !reg.test(str) return status }, res5(str){ let reg = /^[0-9\-()]*$/ let status = !reg.test(str) return status }, res6(a,b,str){ //中英文数字字符 let re = `\^[\u4e00-\u9fa5_a-zA-Z0-9]{${a},${b}}\$` let reg = new RegExp(re); let status = !reg.test(str) return status },