Postal codes (aka ZIP codes) in the United States consist of 5 digits with an optional 4 digit suffix.
Variation | Pattern | |
---|---|---|
US Zip Code (standalone) | ^((\d{5})(-\d{4})?)$ | |
US Zip Code (inline) | \b((\d{5})(-\d{4})?)\b |
{ "detail": "Postal codes (aka ZIP codes) in the United States consist of 5 digits with an optional 4 digit suffix.\n\n[Wikipedia](https://en.wikipedia.org/wiki/ZIP_Code)\n", "featured": true, "handle": "zip-code", "title": "Zip (aka Postal) Codes in the United States", "tags": [ "postal-code", "united-states", "us" ], "variations": [ { "title": "US Zip Code (standalone)", "regex": "^((\\d{5})(-\\d{4})?)$", "replacement": "zip code is \"\\1\"", "inputs": [ "12345", "12345-6789" ] }, { "title": "US Zip Code (inline)", "regex": "\\b((\\d{5})(-\\d{4})?)\\b" } ], "fullPath": "/app/patterns/zip-code.yaml" }