US post code validation

Q

How to perform a validation on US post codes using a regular expression? For example, "12345-5434" is an valid US post code.

✍: Guest

A

To perform a validation on US post codes, try this regular expression:

^([0-9]{5})(-[0-9]{4})?$

Click the button to test this regular expression here online:

2013-01-27, 0👍, 0💬