Regex for US ZIP code

Matches a US ZIP or ZIP+4 postal code.

^\d{5}(-\d{4})?$

Proof it works

5/5 sample tests passed · compiles: true

SampleShould matchResult
94103 yes pass
94103-1234 yes pass
9410 no pass
ABCDE no pass
94103-12 no pass

Try your own input

Related patterns