Regular Expressions 101

US Phone Number Validation (with optional country code and separators)

Open Workspace
  • PCRE2 (PHP)
  • Match
1

Regular Expression

/
^(\+1\s?)?(\(?[2-9][0-9]{2}\)?[\s.-]?)?[2-9][0-9]{2}[\s.-]?[0-9]{4}$
/
gm

Description

Submitted by Anonymous