DevTools Hub

Search tools

Search for a developer tool

Regex for Phone Number

Part of the Regex Toolkit
Pattern
^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

matches common US/Canada formats only — phone numbers have no single international standard

Explanation

Unlike an email address or a UUID, there is no single standard shape for a phone number to check against — a phone number is just whatever a national numbering plan says it is, and those vary by country. This pattern covers the common US and Canada formats: a 3-digit area code (optionally in parentheses), a 3-digit exchange, and a 4-digit line number, separated by a space, dash, or dot — or no separator at all.

The nearest thing to a real international standard is E.164, which allows a 1-to-3-digit country code plus up to 12 more digits — anywhere from 8 to 15 digits total depending on the country, always written with a leading + and no other punctuation. A regex built for 10-digit US numbers simply can't validate that range correctly, which is exactly why this pattern rejects a number written with a +1 country code prefix, even though that number is perfectly valid.

One real limitation worth knowing about even within scope: the two parentheses are each independently optional, not required to appear together — so a malformed string with only an opening or only a closing parenthesis, like (555-123-4567, still matches. If a phone number genuinely needs to work — not just look plausible — the only real test is sending it a code via SMS; for correctly parsing and validating international numbers in real code, reach for a dedicated library like Google's libphonenumber rather than a hand-written regex.

This is the same pattern as the "US phone" preset in Regex Builder, kept anchored here (^/$) for validating that an entire string is one phone number.

Valid examples

  • 555-123-4567

    Dash-separated, the most common US format.

  • (555) 123-4567

    Parenthesized area code with a space before the exchange.

  • 5551234567

    No separators at all — still valid, since every separator in the pattern is optional.

Invalid examples

  • +1 555-123-4567

    A leading +1 country code — this pattern only expects the 10 US/Canada digits, not an E.164-style prefix.

  • 555-1234

    Only 7 digits — missing the 3-digit area code.

  • 555--123--4567

    Doubled separators — each separator slot allows at most one character.

Try it now