Skip to content
← Back

regex-library

Text
Runs locally · Not uploaded

This tool runs entirely in your browser. Open DevTools → Network panel and search your input — it appears in no request.

Usage Guide

"What is the regex for a Chinese phone number" is a question every CJK developer has searched — and half the answers online are stale (still allowing the 12x prefix) or too loose (\d{11} accepts anything starting with 1). This library ships 14 battle-tested patterns verified against samples and counter-samples: CN mobile, resident ID, plates (standard + new-energy), Unified Social Credit Codes, plus email/URL/IPv4/dates and friends. Copy in one click or jump into the online tester to verify live.

1. Notes on the China-format trio

The mobile pattern ^1[3-9]\d{9}$ covers every allocated prefix since MIIT retired 12x — fine for form pre-checks. The new-energy plate pattern encodes the position rules (D/F leads small, trails large, excluded elsewhere), the same logic as this site’s plate validator. The ID pattern only checks shape — the MOD 11-2 check digit is beyond regex; use the validator for strict checks. The credit-code pattern uses the 31-char alphabet, and its mod-31 check digit is likewise regex-proof.

2. Using them in projects

Embed in both client and server validation (client for UX, server for safety). Trim the long ones (URL/IPv6) for readability as needed; before shipping, run every pattern against real samples and hostile inputs (empty, overlong, fullwidth digits) in the tester.

Related Tools

Related Articles