Validationflags: g

US ZIP Code

Match US ZIP codes in 5-digit (12345) and ZIP+4 (12345-6789) formats.

Try it in RegexPro

Pattern

regexJavaScript
/\b\d{5}(?:[\-\s]\d{4})?\b/g

Raw 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

90210

Matches

  • 90210

Input

10001-1234

Matches

  • 10001-1234

Input

1234

No match

Common use cases

  • Address form validation
  • Shipping/logistics data processing
  • Geographic data extraction
  • E-commerce checkout validation
All patternsTest this pattern live →