Regular Expressions 101

Community Patterns

4 digit numeric w/o leading zero and no repeat digits

-2

Regular Expression
PCRE (PHP <7.3)

/
^([1-9])(?!\1)([0-9])(?!\1|\2)([0-9])(?!\1|\2|\3)([0-9])$
/
gm

Description

A pcre that capture a 4-digit numeric that does not allow a leading zero and no repeat digits.

Submitted by Jeff Thompson - 9 years ago