elefcode

Regex pattern

Phone Number Regex — free online tester

Match US / Canada phone numbers in every common written format — with or without country code.

The pattern

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

How it works

Phone numbers are written so many different ways: (555) 123-4567, 555-123-4567, 555.123.4567, 5551234567, +1 (555) 123-4567. This pattern accepts all of them: an optional country code, an optional parenthesised area code, and three groups of digits separated by spaces, dashes, dots, or nothing.

When to use it

  • Extract phone numbers from CSV / spreadsheet imports
  • Find contact numbers in scraped pages
  • Validate North-American phone form fields
  • Clean up customer-support tickets

Tip

For international numbers, replace the 3-3-4 digit pattern with a more permissive `\d[\d\s().-]{6,20}\d` and post-validate with libphonenumber.

Try it on this input

Reach us at (555) 123-4567 during business hours.
Sales: 555-123-4567
Support: 555.123.4567
Direct: 5551234567
With country code: +1 555 123 4567 or +1-555-123-4567
Not a phone: 123, 12-34, abc, random text

What this pattern doesn't catch

  • Matches only North American (NANP) numbers — doesn't accept other country codes
  • Doesn't validate that the area code or prefix is actually assigned
  • Will match phone-like substrings inside longer numbers (e.g. credit cards) — anchor with \b for stricter use

More regex patterns