US ZIP Code
beginnerMatches US ZIP codes in 5-digit or ZIP+4 format.
zippostalusvalidation
Pattern
/\b\d{5}(?:-\d{4})?\b/gTry It
0 of 6 strings matched
Explanation
Matches 5-digit US ZIP codes with optional +4 extension (hyphen followed by 4 digits). Word boundaries prevent partial matches.
Test Strings
Matching
- 90210
- 10001-1234
- 00000
Non-matching
- 1234
- 123456
- ABCDE
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Limited support (ASCII-only word boundaries) |
Code Snippets
const regex = /\b\d{5}(?:-\d{4})?\b/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);