R
Regex Master
TutorialsToolsFAQAboutContact
  1. Home
  2. Tutorials
  3. Validation
  4. International Phone Number Regex Validation (E.164 Standard)
February 20, 2025Regex Master Team11 min read

International Phone Number Regex Validation (E.164 Standard)

Validationphone validationE.164international regexregex patterns

Master phone number validation using regular expressions with E.164 standard support for international formats and country codes.

International Phone Number Regex Validation (E.164 Standard)

Phone number validation is crucial for applications with global users. With varying formats across countries, creating a robust phone validation pattern can be challenging. In this comprehensive guide, we'll explore phone number validation patterns, including E.164 standard compliance and international format support.

Understanding Phone Number Formats

Phone numbers vary significantly across the world:

US Format: (555) 123-4567 or 555-123-4567
UK Format: +44 20 7946 0958
German Format: +49 30 1234567
International E.164: +15551234567

What is E.164 Standard?

E.164 is an international standard for phone number formats. It specifies:

  • Maximum 15 digits
  • Must start with country code (prefixed with +)
  • Only digits 0-9 are allowed
  • Format: +[country code][subscriber number]

Example E.164 number: +15551234567

Simple Phone Number Patterns

US/Canada Format (Common)

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

Matches: 555-123-4567, 555.123.4567, 5551234567

Breakdown:

  • ^\d{3} - Three digits at start
  • [-.]? - Optional separator (- or .)
  • \d{3} - Three digits
  • [-.]? - Optional separator
  • \d{4}$ - Four digits at end

With Country Code (Optional)

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

Matches: +1 555-123-4567, 555-123-4567

E.164 Standard Validation

Strict E.164 Pattern

^\+[1-9]\d{6,14}$

Breakdown:

  • ^ - Start of string
  • \+ - Literal + sign
  • [1-9] - Country code starts with 1-9 (can't be 0)
  • \d{6,14} - 6-14 more digits (total 7-15 digits with country code)
  • $ - End of string

Valid E.164: +14155552671, +442079460958, +8613812345678
Invalid E.164: 0014155552671, +014155552671, +155512345678901234 (too long)

Flexible E.164 with Spaces

^\+[1-9]\d{0,2}[\s-]?\d{3}[\s-]?\d{3}[\s-]?\d{4}$

Allows spaces or hyphens for readability: +1 555-123-4567

International Phone Number Validation

Generic International Pattern

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

This flexible pattern handles most international formats:

  • Optional country code with +
  • Optional parentheses around area code
  • Various separators allowed
  • Variable-length number segments

Pattern Breakdown:

  • ^ - Start of string
  • (\+\d{1,3}[- ]?)? - Optional country code (+ and 1-3 digits)
  • \(?\d{1,4}\)? - Area code (3-4 digits, optional parentheses)
  • [- ]? - Optional separator (hyphen or space)
  • \d{1,4} - Number segment 1
  • [- ]? - Optional separator
  • \d{1,4} - Number segment 2
  • [- ]? - Optional separator
  • \d{1,9}$ - Final segment (up to 9 digits)

Country-Specific Patterns

US/Canada

^(\+1[- ]?)?(\([0-9]{3}\)|[0-9]{3})[- ]?[0-9]{3}[- ]?[0-9]{4}$

Matches: +1 (555) 123-4567, 555-123-4567

UK

^(\+44[- ]?)?(0[1-9]\d{1,4}|1[1-9]\d{1,3}|7[1-9]\d{7,8})$

Matches: +44 20 7946 0958, 020 7946 0958

Germany

^(\+49[- ]?)?(\d{3}[- ]?)?\d{7,8}$

Matches: +49 30 1234567, 030 1234567

France

^(\+33[- ]?)?(0[1-9]\d{8}|[1-9]\d{8})$

Matches: +33 1 23 45 67 89, 01 23 45 67 89

China

^(\+86[- ]?)?(1[3-9]\d{9})$

Matches: +86 13812345678, 13812345678

India

^(\+91[- ]?)?[6-9]\d{9}$

Matches: +91 9876543210, 9876543210

Advanced Validation Techniques

Validate with Country Code Mapping

const countryPatterns = {
  'US': /^\+?1[- ]?(\([0-9]{3}\)|[0-9]{3})[- ]?[0-9]{3}[- ]?[0-9]{4}$/,
  'UK': /^\+?44[- ]?(0[1-9]\d{1,4}|1[1-9]\d{1,3}|7[1-9]\d{7,8})$/,
  'DE': /^\+?49[- ]?(\d{3}[- ]?)?\d{7,8}$/,
  'FR': /^\+?33[- ]?(0[1-9]\d{8}|[1-9]\d{8})$/,
  'CN': /^\+?86[- ]?(1[3-9]\d{9})$/,
  'IN': /^\+?91[- ]?[6-9]\d{9}$/,
};

function validatePhoneNumber(phone, country) {
  const pattern = countryPatterns[country];
  return pattern ? pattern.test(phone) : false;
}

Extract Country Code

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

Capture groups:

  • Group 1: Country code (e.g., +1, +44, +86)
  • Group 2: Phone number without country code

Normalizing Phone Numbers

Strip All Non-Digits

[^\d+]

Replace with empty string to get: 15551234567 from +1 (555) 123-4567

Normalize to E.164 Format

function normalizeToE164(phone) {
  // Remove all non-digits except +
  const cleaned = phone.replace(/[^\d+]/g, '');
  
  // If starts with +, already E.164
  if (cleaned.startsWith('+')) {
    return cleaned;
  }
  
  // If starts with 0 and has country code, remove 0
  // This depends on your application's logic
  return '+' + cleaned;
}

Best Practices

1. Use E.164 for Storage

Always store phone numbers in E.164 format:

// Store in database: +15551234567
// Display to user: (555) 123-4567

2. Validate, Don't Just Format

// GOOD: Validate before formatting
if (e164Regex.test(cleanedPhone)) {
  storeInDatabase(cleanedPhone);
} else {
  showError('Invalid phone number');
}

// BAD: Format without validation
storeInDatabase(formatPhone(userInput));

3. Provide Clear Formatting Help

Guide users on expected format:

<input type="tel" placeholder="+1 555-123-4567" pattern="^\+[1-9]\d{6,14}$">
<small>Format: +Country Code Number (e.g., +1 555-123-4567)</small>

4. Consider SMS Verification

Regex validation isn't enough. Always verify phone numbers via SMS for critical actions:

if (validatePhone(phone)) {
  sendVerificationCode(phone);
  // User enters code to confirm ownership
}

Common Pitfalls

Pitfall 1: Being Too Strict

// BAD: Only allows US format
^\d{3}-\d{3}-\d{4}$

// GOOD: Allows international formats
^(\+\d{1,3}[- ]?)?\(?\d{1,4}\)?[- ]?\d{1,4}[- ]?\d{1,4}[- ]?\d{1,9}$

Pitfall 2: Forgetting Optional Characters

// BAD: Requires parentheses
^\(\d{3}\)\s\d{3}-\d{4}$

// GOOD: Makes parentheses optional
^\(?\d{3}\)?\s?\d{3}[-]?\d{4}$

Pitfall 3: Not Validating Length

// BAD: Allows any length
^(\+\d{1,3})?[\d\s-]+$

// GOOD: Limits to reasonable length
^(\+\d{1,3}[- ]?)?\(?\d{1,4}\)?[- ]?\d{1,4}[- ]?\d{1,4}[- ]?\d{1,9}$

Testing Your Phone Validation

Use our interactive Regex Tester with these test cases:

Valid Numbers:

  • +14155552671 (E.164)
  • +44 20 7946 0958 (UK)
  • 555-123-4567 (US)
  • +86 13812345678 (China)
  • +49 30 1234567 (Germany)

Invalid Numbers:

  • 123 (too short)
  • +155512345678901234 (too long)
  • +014155552671 (country code can't start with 0)
  • abc-123-def (contains letters)

Conclusion

Phone number validation requires balancing flexibility with accuracy. For most applications, a pattern that allows various international formats while encouraging E.164 standard works best.

The pattern ^(\+\d{1,3}[- ]?)?\(?\d{1,4}\)?[- ]?\d{1,4}[- ]?\d{1,4}[- ]?\d{1,9}$ provides good flexibility for international users.

For strict E.164 compliance, use ^\+[1-9]\d{6,14}$.

Remember to combine regex validation with SMS verification for truly reliable phone number authentication. Test your patterns with real phone numbers from your target markets to ensure accuracy.

Experiment with different patterns using our Regex Generator to find the perfect fit for your application!


About the Author

The Regex Master Team consists of experienced developers and technical writers dedicated to simplifying regular expressions for everyone. We ensure all patterns are rigorously tested and verified to provide accurate, production-ready solutions.

Try It: Regex Tester

Use our interactive regex tester to experiment with the patterns you learned in this article. Test your regular expressions in real-time and see immediate results.

Loading tester...

Related Articles

Date Format Regex Validation (YYYY-MM-DD and More)

Learn how to validate date formats using regular expressions, including YYYY-MM-DD, MM/DD/YYYY, and international formats.

Read Article

Credit Card Number Format Validation with Regex

Learn how to validate credit card numbers using regular expressions, including Luhn algorithm and format-specific patterns.

Read Article

Email Validation Regex Explained (Including RFC Standards)

Learn how to validate email addresses using regular expressions, including RFC 5322 standards and practical implementation tips.

Read Article

Hex Color Code Regex Matching Guide

Learn how to validate and extract hex color codes using regular expressions, including 3-digit, 6-digit, and alpha channel formats.

Read Article
R
Regex Master

Your comprehensive guide to mastering regular expressions through tutorials and tools.

Company

  • About Us
  • Contact
  • FAQ

Resources

  • All Articles
  • Popular Tools
  • Sitemap

Legal

  • Privacy Policy
  • Terms of Service
  • Cookie Policy
  • Disclaimer

© 2026 Regex Master. All rights reserved.