Common regular matching in javascript

"The ancients are powerless in learning, but the young and strong kung fu begins with old age."

The common regular matching in javascript is not easy to make regular code words, and it is even more difficult to produce high-quality goods. If you are not particularly lucky, please work hard first, and don't fail because of laziness, and hypocritically attribute the cause to your own bad luck. You must work hard to appear effortless. If this article can bring you a little help, I hope to show your support to Little Brother Flying Rabbit with one click and three links. Thank you all friends.
table of Contents
1. Verify ID
Second, verify the email
Three, verify the phone number
Four, verify QQ
Five, check the password strength
Six, hide the middle 4 digits of the mobile phone number

1. Verify ID

function checkIdCard(idcard) {    var reg = /^[1-9]\d{16}[\dxX]$/;    return reg.test(idcard);}

Second, verify the email

function checkEmail(email) {    var reg = /^\w+([+-.]\w+)*@\w+([-.]\w+)*\.[a-zA-Z]{2,6}$/;    return reg.test(email);}

Three, verify the phone number

function checkPhone(phone) {    var reg = /^1\d{10}$/;    return reg.test(phone);}

Four, verify QQ

function checkQQ(qq) {    var reg = /^[1-9](\d{4,})$/;    return reg.test(qq);}

Five, check the password strength

function checkPwdLevel(pwd) {    //高级密码强度    var reg3 = /^(?![a-zA-z]+$)(?!\d+$)(?![[email protected]#$%^&*.]+$)(?![a-zA-z\d]+$)(?![[email protected]#$%^&*.]+$)(?![\[email protected]#$%^&*.]+$)[a-zA-Z\[email protected]#$%^&*.]+$/;    //二级密码强度    var reg2 = /^(?![a-zA-z]+$)(?!\d+$)(?![[email protected]#$%^&*.]+$)[a-zA-Z\[email protected]#$%^&*.]+$/;    //初级密码强度    var reg1 = /^(?:\d+|[a-zA-Z]+|[[email protected]#$%^&*.]+){6,}$/;     if(reg3.test(pwd)) {        return 3;    } else if (reg2.test(pwd)) {        return 2;    } else if (reg1.test(pwd)) {        return 1;    } else {        return 0;    }}

Six, hide the middle 4 digits of the mobile phone number

function hiddenPhone(phone) {    var reg = /(\d{3})\d{4}(\d{4})/gi;    return phone.replace(reg, "$1****$2");}