Regular Expression To Match Brazilian Postal Codes (CEP)

A regular expression to match postal codes (also called CEP) in Brazil.

/^\d{5}(-\d{3})?$/

Matches:

  • 01000-000
  • 57999-999
  • 79000-000

Non-matches:

  • 01000-abc
  • 01000-0000
  • 01000 000