Advertisement

Pattern library / Validation

Phone Number Regex (Intl & US Formats)

Phone numbers have no single shape: +1-415-555-2671, (415) 555-2671 and 0812-3456-7890 are all valid, all different. This pattern accepts an optional country code, optional parentheses and -/./ separators — then the notes give you the strict E.164 and per-country variants when you need them.

The pattern
^(\+[0-9]{1,3}[-. ]?)?\(?[0-9]{2,4}\)?[-. ]?[0-9]{3,4}([-.\s][0-9]{3,4}){0,2}$
Load this pattern into the tester →

How the pattern works

Test it: match & no-match examples

Every row is loaded straight into the tester — click Try to see the match live:

InputResultWhy
+1-415-555-2671Matchcountry code + NANP with dashesTry →
(415) 555-2671Matchparentheses around the area codeTry →
0812-3456-7890Matchlocal format with separatorsTry →
12345Matchfive digits pass — tighten for production (pitfalls)Try →
call meNo matchletters are not digitsTry →
12-34No matchtoo few digits after the separatorTry →

Where to use it

JavaScript

const PHONE = /^(\+[0-9]{1,3}[-. ]?)?\(?[0-9]{2,4}\)?[-. ]?[0-9]{3,4}([-.\s][0-9]{3,4}){0,2}$/;
PHONE.test('(415) 555-2671'); // true

Python (normalize to E.164)

import re
def e164(s):
    digits = re.sub(r'[^0-9+]', '', s)
    return digits if re.fullmatch(r'\+[1-9][0-9]{1,14}', digits) else None

BigQuery / GA4 (RE2)

SELECT REGEXP_CONTAINS(REPLACE(phone, '-', ''), r'^\+[1-9][0-9]{1,14}$')

Common mistakes

Test this pattern on your own data
Paste it into the free tester with your real strings — nothing leaves your browser.
Open the regex tester →

FAQ

What is the regex for E.164 phone numbers?

^\+[1-9][0-9]{1,14}$ — plus sign, then 9 to 14 more digits, no separators. Strip spaces, dashes and parentheses before testing.

Why does my regex match 12345?

The digit groups allow short runs on purpose — locale-agnostic patterns cannot know your minimum length. Tighten the groups or validate the digit count in code (7–15).

How do I match US numbers only?

^\(?[0-9]{3}\)?[-.\s]?[0-9]{3}[-.\s]?[0-9]{4}$ — exactly 10 digits with optional parentheses and separators, no country code.

Email Validation Regex — Practical Pattern to Test · Country Code Regex - ISO 3166 Alpha-2 / Alpha-3 · Extract Numbers from String — Regex + Examples

For GA4-specific patterns, see the GA4 regex cheat sheet, the page path regex guide, the event filter regex guide, the GA4 regex match types, the custom channel grouping guide and RE2 vs PCRE. Browse the full regex pattern library.