Data & Formatting · In-Browser Regular Expression Lab
Date Regex — Validate ISO 8601 Calendar Dates (YYYY-MM-DD)
Validates 4-digit year, 2-digit month (01-12), and 2-digit day (01-31) in ISO format.
Flags:
//none
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:2026-10-14
Test Samples Verification Matrix
Expected Valid Samples (Should Match)
2026-10-14 Pass
1999-12-31 Pass
2024-02-29 Pass
Expected Invalid Samples (Must Reject)
2026-13-01 Rejected (Pass)
2026-00-15 Rejected (Pass)
2026-04-32 Rejected (Pass)
26-05-2026 Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/;
const text = "2026-10-14";
const isMatch = pattern.test(text);
console.log("Is Match:", isMatch);
if (isMatch) {
const matches = text.match(pattern);
console.log("Matches:", matches);
}Regular Expression Token Breakdown
Validates structural date format with month 1-12 and day 1-31. Each component of the regular expression serves a distinct syntactical purpose as mapped below:
| Token Pattern | Name / Component | Function & Rule |
|---|---|---|
| ^\d{4} | Year | Four-digit Gregorian calendar year. |
| 0[1-9]|1[0-2] | Month | Zero-padded month from 01 to 12. |
| 0[1-9]|[12]\d|3[01] | Day | Zero-padded day of month from 01 to 31. |
Frequently Asked Questions
Can regex detect leap years?
Related Regular Expressions
Browse All 40 PatternsData & Formatting
24-Hour Time Format (HH:mm:ss)
Matches 24-hour military and standard timestamps in HH:mm or HH:mm:ss format.
/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/Test regex
Data & Formatting
ISO 8601 Combined Timestamp
Matches ISO 8601 timestamps like 2026-10-14T22:30:00.000Z or with +/- timezone offsets.
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/Test regex
Data & Formatting
5-Field Cron Expression
Matches standard Unix crontab schedules (minute, hour, day of month, month, day of week).
/^(?:\*(?:\/[0-9]+)?|[0-9,-\/]+)\s+(?:\*(?:\/[0-9]+)?|[0-9,-\/]+)\s+(?:\*(?:\/[0-9]+)?|[0-9,-\/]+)\s+(?:\*(?:\/[0-9]+)?|[0-9,-\/]+|[a-zA-Z]{3})\s+(?:\*(?:\/[0-9]+)?|[0-9,-\/]+|[a-zA-Z]{3})$/Test regex