js常用正则(2)

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
        },

  

posted @ 2018-11-07 15:35  我以为你不在乎  阅读(179)  评论(0编辑  收藏  举报