Developer QA tool

Phone number regex tester

Run a JavaScript regular expression against sample input and inspect every match without sending data to a server.

Test a pattern

A regex is not global phone validation. Numbering plans change and many countries use variable lengths. Prefer a maintained numbering library for production decisions.

Use regex for input shape

A small expression can detect disallowed characters, a missing plus sign or an obvious length boundary. It is useful at the edge of a form when the error message describes only that limited check.

Do not encode a global plan

One expression cannot accurately model every national plan, shared calling code, trunk prefix and future allocation. Treat a match as parseable input, not proof that a destination exists.

Test failure cases

Include empty input, punctuation, extensions, too few and too many digits, unsupported calling codes and pasted text. A good test suite explains why each negative case should fail.

JavaScript regex checklist

CheckWhy it matters
Flagsg, i and u can change matching behavior and repeated execution.
AnchorsUse ^ and $ when the entire field must match, not only one substring.
BacktrackingAvoid nested ambiguous quantifiers that can become slow on long hostile input.
NormalizationDecide whether punctuation is accepted and removed before applying structural checks.