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

TokenDescription
^Anchors at the start of the string (or line in multiline mode)
(?:Start of non-capturing group
\+Matches a literal plus sign
1Matches the literal character '1'
\sMatches 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)
\dMatches 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)
\dMatches 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)
\dMatches 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

InputExpected
(555) 123-4567Match
+1 555-123-4567Match
5551234567Match
123-45-6789No Match
555.123.4567Match

Try It — Interactive Tester

//
gimsuy
No matches found.
Pattern: 53 charsFlags: noneMatches: 0

Ctrl+Shift+C to copy regex

Customize this pattern →