Regex for 4 digit number

Matches a number with exactly 4 digit(s).

^\d{4}$

Proof it works

4/4 sample tests passed · compiles: true

SampleShould matchResult
3074 yes pass
30741 no pass
307 no pass
aaaa no pass

Try your own input

Related patterns