Regex library
Regular expression for ISO dates
A JavaScript regex for YYYY-MM-DD date strings. Shape only — February 31 will still match, so parse after.
^\d{4}-\d{2}-\d{2}$
Runs 100% in your browser. Nothing you paste is uploaded, stored, or sent to a server.
Highlighted matches
How to use
- Scan the pre-filled pattern and the sample. Hits are highlighted; misses stay plain.
- Toggle flags if you need global or case-insensitive matching. The pattern is JavaScript / ECMAScript.
- Paste your own corpus. Nothing is sent to a server.
- Read the notes below before you drop the pattern into production — several of these are intentionally incomplete.
ISO 8601 calendar dates are the least ambiguous way to write a day in a US/EU mixed team. This pattern checks shape: four digits, hyphen, two, hyphen, two.
It will accept 2026-13-40. Regex is the wrong tool for calendar math. After a match, new Date(`${value}T00:00:00Z`) or a date library should reject impossible days.
What this pattern will not do
US 10/19/2026 and EU 19/10/2026 do not match, which is the point.
Date-times with a T and a zone are a different pattern.
FAQ
How do I add a time component?
Something like ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$ for a basic UTC timestamp, then parse it.
Why not validate months 01–12 in the regex?
You can (use (0[1-9]|1[0-2])), but you still cannot handle month lengths cleanly. Parse after the shape check.
Is the sample text uploaded?
No. The tester compiles the pattern with the browser’s RegExp engine and stays on the device.