Skip to main content
hank-builds.com

Phone Number (US) regex

Matches US phone numbers in various formats.

/(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}/g

What it matches

Ten digits in the North American layout, with an optional +1 or 1 prefix, optional parentheses around the area code, and hyphens, dots or spaces as separators. It accepts the written forms people use: (555) 123-4567, 555.123.4567, +1 555 123 4567 and the unpunctuated 5551234567.

Railroad diagram

Read left to right. Every path through the diagram is a string the pattern accepts.

\+ "1" [-.\s] \( {3} \d \) [-.\s] {3} \d [-.\s] {4} \d

Drag to pan. Ctrl+scroll to zoom.

Breakdown

gFind all matches instead of stopping after the first
\+?Literal "+", optional
1Literal "1"
[-.\s]?Match one of: Literal "-", Literal ".", Whitespace, optional
\(?Literal "(", optional
\d{3}Digit (0-9), exactly 3 times
\)?Literal ")", optional
[-.\s]?Match one of: Literal "-", Literal ".", Whitespace, optional
\d{3}Digit (0-9), exactly 3 times
[-.\s]?Match one of: Literal "-", Literal ".", Whitespace, optional
\d{4}Digit (0-9), exactly 4 times

Test cases

Matches

  • (555) 123-4567
  • +1-555-987-6543
  • 5551234567

Does not match

  • 555-1234
  • not a phone number

Caveats

Format only. It cannot tell a real number from 000-000-0000, does not reject reserved area codes, and will find ten digits inside a longer run, so an account number can look like a phone number to it. US and Canada only; for anything international, normalise to E.164 and validate with a library.

More common patterns

Test this against your own input in the regex tester, browse the full pattern library, or check the syntax cheat sheet.