Phone Number Regex — Match and Validate Phone Numbers

Everything you need to validate phone numbers with regular expressions. Patterns for US numbers, international formats, and custom layouts — with a free online tester.

US Phone Number Regex Pattern

(\+\d{1,3}[- ]?)?\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}

Matches US phone numbers with optional country code and various formatting: (555) 123-4567, +1-555-123-4567, 555.123.4567, and 5551234567.

//
Flags:

Substitution

No matches found

How Phone Number Regex Works

Phone number regex patterns need to handle multiple formatting conventions while still catching invalid input. The pattern is built from several optional and required groups:

(\+\d{1,3}[- ]?)?

Country code (optional): Matches a + sign followed by 1-3 digits and an optional separator (dash or space). The entire group is optional with the ? quantifier.

\(?\d{3}\)?

Area code: Matches exactly 3 digits with optional parentheses. The \( and \) escape the special characters, and ? makes each optional.

[- ]?\d{3}[- ]?\d{4}

Phone number: Matches 3 digits, an optional separator, then 4 digits. This handles the standard XXX-XXXX format.

Phone Number Formats by Country

Phone number formats vary significantly around the world. Here are regex patterns for common international formats:

🇺🇸 United States

(\+1[- ]?)?\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}

10 digits with optional +1 country code. Formats: (555) 123-4567, +1-555-123-4567, 555.123.4567

🇬🇧 United Kingdom

(\+44[- ]?)?\d{4}[- ]?\d{6}

10 digits with optional +44 country code. Formats: +44 20 7946 0958, 020 7946 0958

🌐 International (Generic)

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

Flexible pattern that matches many international formats. Good for general-purpose validation when you need to support multiple countries.

Common Phone Number Patterns

Here are the most commonly needed phone regex patterns, ready to copy and use:

US Phone (Flexible)

(\+\d{1,3}[- ]?)?\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}

Matches most US phone formats with optional country code

US Phone (Strict)

^\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}$

Exactly 10 digits, no country code, common separators

International (with +)

^\+\d{1,3}\d{4,14}$

Country code starting with + followed by 4-14 digits

Phone with Extension

(\+\d{1,3}[- ]?)?\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}(\s?(ext|x|ext.)\s?\d{1,5})?

US phone number with optional extension

Digits Only

^\d{10,15}$

Matches phone numbers that are 10-15 digits with no formatting

Phone Regex Edge Cases

Phone number validation has many edge cases. Here's what to watch out for:

Formatting variations

Users may enter (555) 123-4567, 555-123-4567, 555.123.4567, or 5551234567

Country codes

+1 for US, +44 for UK, +86 for China — make them optional for domestic apps

Extensions

Some numbers include ext 123 or x456 at the end

Toll-free numbers

800, 888, 877, 866, 855, 844, 833 are US toll-free prefixes

Short codes

SMS short codes (like 12345) are only 5 digits

International prefixes

00 is the international dialing prefix in many countries (instead of +)

Best Practices for Phone Number Validation

  • Normalize before validating

    Strip all non-digit characters (except leading +) before applying regex. This handles different formatting conventions automatically.

  • Be flexible with input format

    Accept multiple formats and normalize internally. Users should be able to enter phone numbers however they're comfortable.

  • Use regex for format, not existence

    Regex can verify a number looks valid but cannot confirm it exists. For critical applications, use SMS or call verification.

  • Consider using a specialized library

    For international phone validation, Google's libphonenumber provides more accurate results than regex alone.

Phone Regex in Code

Here's how to use phone number regex in popular programming languages:

JavaScript

const phoneRegex = /^(\+\d{1,3}[- ]?)?\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$/;
const isValid = phoneRegex.test("(555) 123-4567"); // true

Python

import re
phone_regex = r'^(\+\d{1,3}[- ]?)?\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$'
is_valid = re.match(phone_regex, "+1-555-123-4567")

Test Your Phone Regex Now

Use the tester above to verify your phone number regex with actual data. Free, instant, and private.