Regex for Phone Number Validation
Quick Answer: Phone numbers vary wildly by country. For US numbers: ^\+?1?[-.\s]?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$. For international, use the libphonenumber library instead of regex -- it handles 200+ country formats and validates carrier prefixes.
FAQ
Can regex validate all phone number formats?
No. Phone formats vary by country (length, prefixes, grouping). Regex works for single-country validation. For international numbers, use Google libphonenumber.
What is the E.164 phone number format?
E.164 is the international standard: +[country code][subscriber number], max 15 digits. Example: +14155552671. Regex: ^\+[1-9]\d{1,14}$.