Regular Expressions 101

Community Patterns

US Number (Match) [freeCodeCamp]

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(1\s?)?(\(\d{3}\)\s?|\d{3}[\-|\s]?)(\d{3}[\-|\s]?)(\d{4})
/
g

Description

It's easy to think about it section by section.

Submitted by Alex - 2 years ago