Pattern library/ISO date (YYYY-MM-DD) regex
ISO date (YYYY-MM-DD) regex
Anchored-style date matching for logs and filenames. Does not validate all calendar edge cases (e.g. Feb 30).
Expression
/\b(?:19|20)\d{2}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])\b/gHow to read it
(?:19|20)\d{2}Year 1900–2099(?:0[1-9]|1[0-2])Month 01–12(?:0[1-9]|[12]\d|3[01])Day 01–31
Sample test
2 match(es)Shipped on 2024-03-15, due 2025-12-01. Ignore 03/15/2024 and 2024-13-40.
Starter prompt: match ISO dates YYYY-MM-DD