Regular Expressions 101

Community Patterns

Community Library Entry

-1

Regular Expression
PCRE (PHP <7.3)

/
(1(\s|-)?)?(\+\d{1,3}\s?)?((\(\d{3}\)\s?)|(\d{3})(\s|-?))(\d{3}(\s|-?))(\d{4})(\s?(([E|e]xt[:|.|]?)|x|X)(\s?\d+))?
/
gm

Description

Original regex at https://www.regextester.com/103299. I added a check for US country code in front of the area code

Submitted by anonymous - 4 years ago