explaingit

vincentsit/chinamobilephonenumberregex

4,772Audience · developerComplexity · 1/5LicenseSetup · easy

TLDR

A collection of copy-paste regular expressions for validating Chinese mobile phone numbers, covering all four major carriers, MVNOs, IoT SIMs, and data-only numbers. Works in any programming language. Includes a carrier prefix reference table and a note that number portability since 2019 means carrier detection is unreliable.

Mindmap

mindmap
  root((repo))
    Carriers
      China Mobile
      China Unicom
      China Telecom
      China Broadcast Network
    Number Types
      Standard Mobile
      MVNO Virtual
      IoT 13 Digit
      Data Only
    Usage
      Copy Paste Regex
      Multi Language
      Catch All Pattern
    Reference
      Prefix Table
      Online Test Tools
      Release History
    Limitations
      Number Portability
      No Carrier Guarantee
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Validate a phone number field in a sign-up form to ensure users enter a real Chinese mobile number

USE CASE 2

Filter or segment a contact list by number type, such as separating IoT SIMs from regular mobile numbers

USE CASE 3

Add server-side phone number validation to a backend written in Python, JavaScript, Java, or any other language

USE CASE 4

Check whether a submitted number belongs to a known mainland China prefix range before sending an SMS

Tech stack

Regex

Getting it running

Difficulty · easy Time to first run · 5min

No installation needed. Copy the relevant regex pattern from the README directly into your project. Test instantly using the linked online regex tools.

MIT license, free to use, copy, modify, and distribute in any project, personal or commercial. No restrictions.

In plain English

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.

Copy-paste prompts

Prompt 1
I have a user registration form. Using the regex patterns from vincentsit/chinamobilephonenumberregex, write a JavaScript function that validates a mainland China mobile phone number and returns an error message if it is invalid.
Prompt 2
Using the patterns from vincentsit/chinamobilephonenumberregex, write a Python function that accepts a phone number string and returns which category it belongs to: standard mobile, MVNO, IoT, data-only, or unknown.
Prompt 3
I need to validate Chinese mobile numbers in a Java Spring Boot application. Show me how to integrate the catch-all regex from vincentsit/chinamobilephonenumberregex into a field validator annotation.
Prompt 4
Explain to a non-technical founder why matching a Chinese phone number to a carrier prefix no longer reliably identifies the current carrier, and what that means for an SMS marketing campaign.
Prompt 5
Write a Node.js Express middleware that rejects any request body where the phone field does not match a valid mainland China mobile number, using the regex from vincentsit/chinamobilephonenumberregex.
Open on GitHub → Explain another repo

← vincentsit on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.