Basic International Pattern

Matches optional +country code and common separators.

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

Example

+1 415-555-2671
+44 20 7946 0958
(212) 555-1234

Strict 10-Digit US Number

^(?:\+1[\s.-]?)?\(?[2-9]\d{2}\)?[\s.-]?\d{3}[\s.-]?\d{4}$

Example

2125551234
+1 (415) 555-2671

Input Sanitization Before Validation

Strip spaces, dashes, and parentheses before applying strict patterns.

value.replace(/[\s()-]/g, '')

Common mistakes / Pitfalls

  • People often copy a command or pattern without adapting placeholders, which can break production workflows unexpectedly.
  • It is easy to forget environment-specific differences, so always verify behavior in your shell, runtime, or API gateway before shipping.
  • Many errors come from skipping small validation steps, so test with realistic sample input before relying on the result.
Last updated: February 2026