Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2025-12-23 19:40
Flavor·PCRE2 (PHP)

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

Description

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

Submitted by Nick