Skip to content

Instantly share code, notes, and snippets.

@feix
Forked from JerryC8080/RexChainesPhone.js
Created April 9, 2020 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feix/3b0af5f42d58c71189af280e21e7837c to your computer and use it in GitHub Desktop.
Save feix/3b0af5f42d58c71189af280e21e7837c to your computer and use it in GitHub Desktop.
匹配中国电话号码的正则表达式
/**
电信
中国电信手机号码开头数字
2G/3G号段(CDMA2000网络)133、153、180、181、189
4G号段 177
联通
中国联通手机号码开头数字
2G号段(GSM网络)130、131、132、155、156
3G上网卡145
3G号段(WCDMA网络)185、186
4G号段 176、185[1]
移动
中国移动手机号码开头数字
2G号段(GSM网络)有134x(0-8)、135、136、137、138、139、150、151、152、158、159、182、183、184。
3G号段(TD-SCDMA网络)有157、187、188
3G上网卡 147
4G号段 178
从以上我们可以看到第一位是【1】开头,第二位则则有【3,4,5,7,8】,第三位则是【0-9】,第三位之后则是数字【0-9】。从而我们可以得出一个符合当前的手机号码验证正则表达式。
* /
!/^1[3|4|5|7|8][0-9]{9}$/.test(phone)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment