Regex Phone 数値 パターン リファレンス
リファレンス 用 phone 数値 validation regex パターン 用 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
- US
- +1 + 10 digits
- China
- +86 1[3-9] + 9 digits
+CC... or display format 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
- E.164 store
- Canonical format
- libphonenumber
- Google library
normalize +CC... all countries