Last active
October 10, 2020 12:47
-
-
Save fhefh2015/3ae42020477620e19eb18a388eae304c to your computer and use it in GitHub Desktop.
2020最新移动 联通 电信号码正则
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://juejin.im/post/6844904109800161294 | |
//2020最新移动,联通,电信号码正则 | |
//由于新增了197、199、190等新号段,最新移动,电信,联通号段如下: 移动号段: 134、135、136、137、138、139、147、150、151、152、157、158、159、172、178、182、183、184、187、188、195 、198、197 | |
//联通号段: 130、131、132、145、146、155、156、166、170、171、175、176、185、186、196 | |
//电信号段: 133、141、149、153、173、174、177、179、180、181、189、191、193、199、190 | |
//手机号码验证(号码验证没有特别严谨): | |
function isMobile(s) { | |
let reg = /^1[3|4|5|6|7|8|9][0-9]{9}$/; //验证规则 | |
let flag = reg.test(s); //true | |
return flag; | |
} | |
//移动号码验证: | |
function isYdmobile(s){ | |
let yd = /1(3[4-9]|4[7]|5[012789]|7[28]|8[23478]|9[578])\d{8}/; //验证规则 | |
let flag = yd.test(s); //true | |
return flag; | |
} | |
//联通号码验证: | |
function isLtmobile(s){ | |
let lt = /1(3[0-2]|4[56]|5[56]|6[6]|7[0156]|8[56]|9[6])\d{8}/; //验证规则 | |
let flag = lt.test(s); //true | |
return flag; | |
} | |
//电信号码验证: | |
function isDxmobile(s){ | |
let dx = /1(3[3]|4[19]|5[3]|7[3479]|8[019]|9[0139])\d{8}/; //验证规则 | |
let flag = dx.test(s); //true | |
return flag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment