Regex to Match US Phone Numbers
Validate US phone numbers with this regex pattern. Matches formats like (555) 123-4567, 555-123-4567, and +1 5551234567. Free regex tester.
Regular Expression
/^(?:\+1\s?)?(?:\(?\d{3}\)?[\s.-]?)?\d{3}[\s.-]?\d{4}$/
Token Breakdown
| Token | Description |
|---|---|
| ^ | Anchors at the start of the string (or line in multiline mode) |
| (?: | Start of non-capturing group |
| \+ | Matches a literal plus sign |
| 1 | Matches the literal character '1' |
| \s | Matches any whitespace character (space, tab, newline) |
| ? | Makes the preceding element optional (zero or one times) |
| ) | End of group |
| ? | Makes the preceding element optional (zero or one times) |
| (?: | Start of non-capturing group |
| \( | Matches a literal opening parenthesis |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {3} | Matches exactly 3 times |
| \) | Matches a literal closing parenthesis |
| ? | Makes the preceding element optional (zero or one times) |
| [\s.-] | Character class — matches any one of: \s.- |
| ? | Makes the preceding element optional (zero or one times) |
| ) | End of group |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {3} | Matches exactly 3 times |
| [\s.-] | Character class — matches any one of: \s.- |
| ? | Makes the preceding element optional (zero or one times) |
| \d | Matches any digit (0-9) |
| {4} | Matches exactly 4 times |
| $ | Anchors at the end of the string (or line in multiline mode) |
Detailed Explanation
This regex validates US phone numbers in multiple common formats. Here is the token-by-token breakdown:
^ — Anchors the match at the start of the string.
(?:+1\s?)? — An optional non-capturing group matching the US country code. It matches a literal '+1' followed by an optional whitespace character. This allows formats like '+1 555-123-4567'.
(?:(?\d{3})?[\s.-]?)? — An optional non-capturing group for the area code. (? matches an optional opening parenthesis. \d{3} matches exactly three digits for the area code. )? matches an optional closing parenthesis. [\s.-]? matches an optional separator (space, dot, or hyphen) after the area code. The entire group is optional to allow seven-digit local numbers.
\d{3} — Matches three digits for the exchange code (the first part of the local number).
[\s.-]? — Matches an optional separator between the exchange code and subscriber number.
\d{4} — Matches four digits for the subscriber number (the last four digits).
$ — Anchors the match at the end of the string.
This pattern accommodates the most common US phone number formats: (555) 123-4567, 555-123-4567, 555.123.4567, 5551234567, and variations with the +1 country code. It is flexible enough for user input validation while still ensuring the correct number of digits.
Example Test Strings
| Input | Expected |
|---|---|
| (555) 123-4567 | Match |
| +1 555-123-4567 | Match |
| 5551234567 | Match |
| 123-45-6789 | No Match |
| 555.123.4567 | Match |
Try It — Interactive Tester
53 charsFlags: noneMatches: 0Ctrl+Shift+C to copy regex
Related Regex Patterns
Regex to Match International Phone Numbers
/^\+?\d{1,3}[\s.-]?\(?\d{1,4}\)?[\s.-]?\d{1,4}[\s.-]?\d{1,9}$/
Regex to Match Social Security Numbers
/^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$/
Regex to Match Credit Card Numbers
/^(?:4\d{3}|5[1-5]\d{2}|3[47]\d{2}|6(?:011|5\d{2}))[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{1,4}$/
Regex to Match US Zip Codes
/^\d{5}(?:-\d{4})?$/