Common use cases
- ✓CSV and import format checks
- ✓Form input normalization
- ✓Log and filename date validation
Validate the common four-digit-year, two-digit-month, two-digit-day shape while constraining months to 01–12 and days to 01–31. The pattern is useful for format validation, but calendar semantics such as February 30 still require a real date parser.
^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$Flags: none
Enter one value per line. Each line is tested against the whole-string pattern using the browser JavaScript RegExp engine.
2026-08-172000-01-011999-12-312026-8-172026-13-012026-00-1017-08-2026Use regex when you need to enforce the YYYY-MM-DD text shape. Use a date parser after the regex if you must reject impossible calendar dates such as 2026-02-31.
2026-08-172000-01-011999-12-312026-8-172026-13-012026-00-1017-08-2026No. It validates the numeric YYYY-MM-DD format and broad month/day ranges. Calendar-validity checks belong in a date parser.
The target format is fixed-width YYYY-MM-DD, so January 5 is written 2026-01-05 rather than 2026-1-5.
No. Timestamps add time, optional fractional seconds, and timezone information, so they require a different pattern or, preferably, an ISO date-time parser.
Move from a live JavaScript regex test to capture-group inspection, flag behavior, literal escaping, focused pattern references, and debugging guides without treating each regex task as an isolated page.