Regular Expressions 101

Community Patterns

10-digit phone number with hyphens

1

Regular Expression
PCRE (PHP <7.3)

/
^\d{3}-\d{3}-\d{4}$
/
gm

Description

Such as 333-333-1234.

Does not test for valid sequences of digits. E.g. 000-000-0000 would pass.

Submitted by anonymous - 8 years ago