Regex for US ZIP codes
Example pattern below—edit it or paste your own. All processing runs in your browser. For Python’s re module, switch flavor in the tool.
Flavor
Standard `RegExp` for explanation and preview.
g i m s u y d v (JavaScript)
Ship to 90210 or 10001-1234.
Plain-English explanation
Flavor: JavaScript RegExp
Flags: g (find all matches)
a word boundary Then Match digit character (0–9), repeated exactly 5 times. Then Match (non-capturing): Match the character "-". Then Match digit character (0–9), repeated exactly 4 times, optional. Then a word boundary