Regular Expression to validate the US zip codes

Here is a Regular Expression to validate the united states 5 and 9 digit zip codes:

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

Basic Validations:
• First five letters should be digits.
• It can be followed by a dash and optional 4 digits

Tagged , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.