Giter Site home page Giter Site logo

vincentsit / chinamobilephonenumberregex Goto Github PK

View Code? Open in Web Editor NEW
4.8K 163.0 500.0 79 KB

Regular expressions that match the mobile phone number in mainland China. / 一组匹配**大陆手机号码的正则表达式。

License: MIT License

phone-number regular-expression mainland-china china-unicom china-mobile china-telecom regex

chinamobilephonenumberregex's Introduction

ChinaMobilePhoneNumberRegex

ChinaMobilePhoneNumberRegex is still actively maintained, we are committed to fixing bugs and merging good quality PRs from the wider community.

A set of regular expressions to match the mobile phone number in mainland China.

Limitation

The mobile number portability(MNP) service in mainland China has been officially available on December 1, 2019, China Standard Time. It is no longer accurate to detect carriers by mobile phone numbers. However, there is no alternative.

Regular Expressions (PCRE)

If you need POSIX standard regular expressions, Click here.

Match all numbers (Phone number + IoT number + Data only number)

^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[0-35-9]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0-35-9]\d{2}|6[2567]\d{2}|4(?:(?:10|4[01])\d{3}|[68]\d{4}|[579]\d{2}))\d{6}$

Match all numbers with SMS (Phone number + Data only number)

^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[0-35-9]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0-35-9]\d{2}|6[2567]\d{2}|4[579]\d{2})\d{6}$

Mobile phone number

Match all

^(?:\+?86)?1(?:3\d{3}|5[^4\D]\d{2}|8\d{3}|7(?:[235-8]\d{2}|4(?:0\d|1[0-2]|9\d))|9[0-35-9]\d{2}|66\d{2})\d{6}$

Match China Mobile

^(?:\+?86)?1(?:3(?:4[^9\D]|[5-9]\d)|5[^3-6\D]\d|7[28]\d|8[23478]\d|9[578]\d)\d{7}$

Match China Unicom

^(?:\+?86)?1(?:3[0-2]|[578][56]|66|96)\d{8}$

Match China Telecom

^(?:\+?86)?1(?:3(?:3\d|49)\d|53\d{2}|8[019]\d{2}|7(?:[37]\d{2}|40[0-5])|9[0139]\d{2})\d{6}$

Match China Broadcast Network

^(?:\+?86)?192\d{8}$

Match Inmarsat (Satellite Communications)

^(?:\+?86)?1749\d{7}$

Match Emergency Communication Support Center of MIIT (Emergency communications)

^(?:\+?86)?174(?:0[6-9]|1[0-2])\d{6}$

MVNO number

Match all

^(?:\+?86)?1(?:7[01]|6[257])\d{8}$

Match China Mobile

^(?:\+?86)?1(?:65\d|70[356])\d{7}$

Match China Unicom

^(?:\+?86)?1(?:70[4789]|71\d|67\d)\d{7}$

Match China Telecom

^(?:\+?86)?1(?:70[012]|62\d)\d{7}$

IoT number

Match all

^(?:\+?86)?14(?:[14]0|41|[68]\d)\d{9}$

Match China Mobile

^(?:\+?86)?14(?:4[01]|8\d)\d{9}$

Match China Unicom

^(?:\+?86)?146\d{10}$

Match China Telecom

^(?:\+?86)?1410\d{9}$

Data only number

Match all

^(?:\+?86)?14[579]\d{8}$

Match China Mobile

^(?:\+?86)?147\d{8}$

Match China Unicom

^(?:\+?86)?145\d{8}$

Match China Telecom

^(?:\+?86)?149\d{8}$

Test/Debug Online

https://regex101.com
https://regexr.com
https://www.debuggex.com (PCRE visualizer)

Rules

Carrier

  • Voice calls / SMS / Data traffic
  • 11 digits
Carrier [1] Prefix
China Mobile 134-0~8 / 135 / 136 / 137 / 138 / 139 / 150 / 151 / 152 / 157 / 158 / 159 / 172 / 178 / 182 / 183 / 184 / 187 / 188 / 195 / 197 / 198
China Unicom 130 / 131 / 132 / 155 / 156 / 166 / 175 / 176 / 185 / 186 / 196
China Telecom 133 / 134-9 / 153 / 173 / 174-00~05 / 177 / 180 / 181 / 189 / 190 / 191 / 193 / 199
China Broadcast Network 192
Inmarsat (Satellite) [2] 174-9
Emergency Communication Support Center of MIIT (Emergency communications) 174-06~12

MVNO

  • Voice calls / SMS / Data traffic
  • 11 digits
Carrier [1] Prefix
China Mobile 165 / 1703 / 1705 / 1706
China Unicom 167 / 1704 / 1707 / 1708 / 1709 / 171
China Telecom 162 / 1700 / 1701 / 1702

IoT

  • Data traffic
  • 13 digits
Carrier [1] Prefix
China Mobile 1440X / 1441X / 148XX
China Unicom 146XX
China Telecom 1410X

Data-plans only

  • Voice calls (Partial) / SMS / Data traffic
  • 11 digits
Carrier [1] Prefix Voice calls [3]
China Mobile 147 Yes
China Unicom 145 No
China Telecom 149 Yes
  1. Since MNP has been piloted in some areas, for users who have changed to another carrier, the mobile phone number prefix can no longer reflect its current carrier.
  2. Operated by China Transport Telecommunication & Information Center.
  3. According to the relevant documents of the MIIT, the voice call function is allowed in 145 / 147 / 149 prefixes, carriers can decide whether to provide voice call function according to the needs of their customers. At present, the 147 / 149 prefixes that support voice calls is available.

Reference

Telephone numbers in China - Wikipedia

Stay up to date

Since the mobile phone number regular expression is time-sensitive, when any regular expression is updated, a new version will be released to trigger GitHub's mail system to notify all users who are watching the repository. If you want to be notified when any regular expressions are updated, please watch this repository.

How to watch releases for a repository?

Release Notes

May 3, 2020

  • Add support for 1441 prefix.

April 16, 2020

  • Add support for 192 prefix.

April 7, 2020

  • Add support for 172 prefix.

December 26, 2019

  • Add support for 190 / 196 / 197 prefix.

December 24, 2019

  • Add support for 162 / 193 / 195 prefix.

December 1, 2019

  • Add reminder for mobile number portability service.

January 10, 2019

  • Optimize the compatibility of some regular expressions in JavaScript.

January 7, 2019

  • Add support for 165 prefix.

December 30, 2018

  • Add an optional country code match.
  • Add regular expression visualization links.
  • Fix 17X prefix cannot match when matching non-174X prefix (e.g. 178).
  • Fix non-numbers in negated character classes is not excluded.
  • Optimize some regular expressions.

December 29, 2018

  • Add support for 146 / 149 / 167 / 191 / 1440X / 148XX / 1410X / 174-00~05 / 174-06~12 / 174-9 prefix.

August 9, 2017

  • Add support for 166 / 198 / 199 prefix.

October 15, 2016

  • Add English documentation.
  • Add support for 175 prefix.
  • Remove test project.
  • Fix 1349 matching issues.

April 5, 2016

  • Add the 171 prefix support.
  • Separate 14* prefix matching.
  • Improve the MVNO prefix matching.

December 19, 2014

  • Initial release.

License

MIT

chinamobilephonenumberregex's People

Contributors

vincentsit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chinamobilephonenumberregex's Issues

Update for the past year changes.

There have been some new changes over the past year, such as the newly added 191 and IoT numbers. Will be updated when there is time in the near future. PRs are also welcome.

Read the wiki if you want to know the detailed changes. ( In Chinese).

172号段

今天有个172号段的用户,可以收短信,但咱这个里面好像没有收录
谢谢

提交个bug

serialVersionUID = 6576896619930983584L;QQQ+8615838471111 wwww55555

正确的结果应该输出:15838471111

正则匹配输出:['19930983584', '+8615838471111']

多语言单元测试

能否加上不同语言的单元测试,规则变更后,需要确保有全部覆盖到

Release Notes

English

This issue contains the release notes, please subscribe this issue in order to get the latest regular expressions.

2016.10.15

  • Add English documentation.
  • Add support for 175* numbers.
  • Remove test project.
  • Fix 1349* matching issues.

2016.4.5

  • Add the 171* numbers support.
  • Separation 14* numbers matching.
  • Improve the virtual operator segment matching.

2014.12.19

Initial release.

中文

这个 issue 包含了更新记录,请关注这个 issue 以获取最新的正则表达式。

2016.10.15

  • 添加英文文档。
  • 添加 175 号段支持.
  • 移除测试工程。
  • 修复 1349* 号段匹配问题。

2016.4.5

  • 添加 171 号段支持。
  • 分离 14* 号段匹配。
  • 完善虚拟运营商号段匹配。

2014.12.19

初次发布。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.