Regular Expressions 101

Community Patterns

US Phone Number Validation

1

Regular Expression
PCRE2 (PHP >=7.3)

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

Description

Captures every kind of US format I can think of (e.g +1999-999-999, 999-999-9999, +1(999) 999-9999, etc). Remove first coupling group if you don't want a country code.

Submitted by Kayla B, - 11 days ago