Zum Inhalt springen
uencoder

Regex Phone Zahl Muster Referenz

Referenz für phone Zahl validation regex Muster für various country formats.

Format Variations

US/Canada: ^\+1\d{10}$ (E.164) or ^\(\d{3}\)\s?\d{3}-\d{4}$ (display). International E.164: ^\+[1-9]\d{1,14}$ (max 15 digits). UK: ^\+44\d{10}$ or 0\d{10}$. China: ^\+861[3-9]\d{9}$ (mobile). Common separators: spaces, dashes, dots, parentheses. Extensions: x\d+ or ext\d+. The E.164 format is the canonical international standard. For robust validation, use libphonenumber which handles all country formats and rules.

E.164
International standard
+CC...
US
+1 + 10 digits
or display format
China
+86 1[3-9] + 9 digits
mobile

Normalization Strategy

Extract digits only: replace all non-digits with empty string. Determine country code from leading digits or context. Validate length and prefix for the country. Format for display according to local conventions. Store in E.164 for consistency. Handle extensions separately. Mobile vs landline distinction requires country-specific rules. libphonenumber (Google) is the gold standard for parsing, validation, and formatting. Never rely solely on regex for phone validation across countries.

extract digits
Remove non-digits
normalize
E.164 store
Canonical format
+CC...
libphonenumber
Google library
all countries

Verwandte Tools

参考链接