Here is a Regular Expression to validate the united states 5 and 9 digit zip codes:
• First five letters should be digits.
• It can be followed by a dash and optional 4 digits
More from: Java Regular Expressions
- Regular Expression to validate the US zip codes
- Java Regular Expressions – Single World Replacement Example /Tutorial
- How To Find Wild Cards In A String Using Regular Expressions?
- How to find if a string is contained in another string using regex in Java?
- Programmatically Validating US and Canada Phone Numbers Using Regular Expressions In Java
- Java Regular Expressions (Theory, Classes and Syntax)
- How to validate PO Box Address Variations With Java Regular Expressions?
- Replacing non-ASCII characters using Java Regular Expressions
- US 5 and 9 Digits Zip Code Validation In Java Using Regular Expressions