Regular Expressions 101

U.S. Phone Number

Open Workspace
  • PCRE2 (PHP)
  • Match
1

Regular Expression

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

Description

Format validation for U.S. phone numbers with or without a country code and with various formatting and punctuation permissible.

Submitted by Nick