InRegex Logo
InRegex

US Zip Codes

Explication

This regex pattern matches US Zip Codes in the format of 5 digits or 5 digits followed by a hyphen and 4 digits. The \b ensures that the zip code is a whole word.

javascript

Expression Régulière

\b\d{5}(?:-\d{4})?\b
Copier
Avez-vous des Retours ?
javascript

Exemple d'Utilisation

const regex = /\b\d{5}(?:-\d{4})?\b/g;
const zipCodes = '12345, 54321-6789, 98765'.match(regex);
Copier

Testez l'expression

Expressions Régulières Similaires