Skip to main content
Regexflux

US Phone Number

beginner

Matches US phone numbers in various common formats.

phonevalidationustelephone

Pattern

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

Try It

0 of 7 strings matched

Explanation

Matches US phone numbers with optional country code (+1), area code with optional parentheses, and groups separated by hyphens, spaces, or dots.

When to Use

Use this pattern to validate or extract US phone numbers from form inputs, contact pages, or text content. It handles the most common formats: (555) 123-4567, 555-123-4567, 555.123.4567, and +1-555-123-4567. This pattern does not validate whether the area code is actually assigned. For production phone validation with international support, consider a library like libphonenumber.

Step-by-Step Breakdown

TokenExplanation
(?:\+?1[-\s.]?)?Optionally match the US country code: an optional +, the digit 1, and an optional separator (hyphen, space, or dot)
\(?Match an optional opening parenthesis before the area code
\d{3}Match exactly 3 digits — the area code (e.g., 555)
\)?Match an optional closing parenthesis after the area code
[-\s.]?Match an optional separator: hyphen, whitespace, or dot
\d{3}Match exactly 3 digits — the central office (exchange) code
[-\s.]?Match an optional separator between the exchange and subscriber number
\d{4}Match exactly 4 digits — the subscriber (line) number

Common Mistakes

Using \d{10} to match any 10 consecutive digits

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

A flat \d{10} matches any 10-digit sequence including zip codes, serial numbers, and other non-phone data. A structured pattern with separators is far more precise.

Requiring parentheses around the area code

Fix: \(?\d{3}\)?

Not all US phone formats use parentheses. Making them optional with \(? and \)? ensures the pattern matches both (555) 123-4567 and 555-123-4567.

Only allowing hyphens as separators

Fix: [-\s.]?

US phone numbers are commonly written with dots (555.123.4567), spaces (555 123 4567), or no separators (5551234567) in addition to hyphens.

Test Strings

Matching

  • (555) 123-4567
  • +1-555-123-4567
  • 555.123.4567
  • 5551234567

Non-matching

  • 123-456
  • 555-1234-567
  • abc-def-ghij

Language Compatibility

LanguageSupport
JSFull support
PYTHONFull support
JAVAFull support
PHPFull support
GOFull support
RUBYFull support
CSHARPFull support

Code Snippets

const regex = /(?:\+?1[-\s.]?)?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);

Common Variations

Strict format

\(\d{3}\) \d{3}-\d{4}

Only matches (555) 123-4567 format

Related Patterns

Learn the Concepts

This pattern uses concepts covered in these lessons: