Validationflags: g
US ZIP Code
Match US ZIP codes in 5-digit (12345) and ZIP+4 (12345-6789) formats.
Try it in RegexProPattern
regexJavaScript
/\b\d{5}(?:[\-\s]\d{4})?\b/gRaw source: \b\d{5}(?:[\-\s]\d{4})?\b
How it works
Core is 5 digits. The optional group (?:[\-\s]\d{4})? adds support for the ZIP+4 extension separated by hyphen or space.
Examples
Input
90210Matches
90210
Input
10001-1234Matches
10001-1234
Input
1234No match
—Common use cases
- Address form validation
- Shipping/logistics data processing
- Geographic data extraction
- E-commerce checkout validation