Validate a phone number field in a sign-up form to ensure users enter a real Chinese mobile number
Filter or segment a contact list by number type, such as separating IoT SIMs from regular mobile numbers
Add server-side phone number validation to a backend written in Python, JavaScript, Java, or any other language
Check whether a submitted number belongs to a known mainland China prefix range before sending an SMS
No installation needed. Copy the relevant regex pattern from the README directly into your project. Test instantly using the linked online regex tools.
This repository is a collection of regular expressions for validating and matching mobile phone numbers from mainland China. A regular expression is a compact pattern that a program can use to check whether a string of text matches a specific format. These patterns are language-agnostic, meaning developers can copy them directly into projects written in Python, JavaScript, Java, or nearly any other programming language. China's phone system is more complex than most countries because it separates numbers by carrier, number type, and service capability. The repository covers standard mobile phone numbers from the four main carriers (China Mobile, China Unicom, China Telecom, and China Broadcast Network), as well as MVNO numbers (virtual operators who resell capacity on those networks), IoT numbers (13-digit SIM slots used in connected devices), and data-only numbers (SIMs that may not support voice calls). Separate patterns are provided for each category so developers can match the exact subset they need, or use a single catch-all pattern if any valid mainland number will do. One important caveat is noted clearly in the README: since December 2019, China has allowed mobile number portability, meaning customers can switch carriers while keeping the same number. As a result, matching a number against a carrier-specific pattern will tell you what prefix range the number came from originally, not necessarily the carrier the person uses today. The maintainer flags this limitation openly and notes there is no technical workaround. The repository also includes links to online tools where you can paste a number and test a pattern in real time, a reference table listing which number prefixes belong to which carriers, and a release history showing how the patterns have grown over the years as new number ranges were assigned by China's Ministry of Industry and Information Technology. The project is actively maintained, released under the MIT license, and accepts community pull requests for new prefix additions.
← vincentsit on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.