Regular Expressions 101

Community Patterns

1...34567...901

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
\+?(\d?)[-\(\.]?(\d{3})[-\)\.\s]?(\d{3})[-\.\s]?\d{4}
/
gm

Description

Will verify a number that matches the pattern: [US International Code], [3-digit Area Code], [3 digits], [4 digits] And will return matches for all the digits together as a string (useful for href="tel:{number"), and each component of the number (including US International Code

Submitted by MegaSpaceHamlet - 3 years ago