Javascript Regex Literal:
US Zip Codes: /(^d{5}$)|(^d{5}-d{4}$)/
/(^d{5}$)|(^d{5}-d{4}$)/
var isValidZip = /(^d{5}$)|(^d{5}-d{4}$)/.test("90210");
Some countries use Postal Codes, which would fail this pattern.
2.1m questions
2.1m answers
60 comments
56.8k users