Skip to main content
Data & Formatting · In-Browser Regular Expression Lab

Cron Expression Regex — Validate Standard 5-Field Schedules

Matches standard Unix crontab schedules (minute, hour, day of month, month, day of week).

Flags:
//none
Match Found
Load Sample:
Match Inspection & Details1 match
Match #1:0 0 * * *

Test Samples Verification Matrix

Expected Valid Samples (Should Match)

0 0 * * * Pass
*/15 * * * * Pass
30 4 1,15 * 5 Pass

Expected Invalid Samples (Must Reject)

0 0 * * Rejected (Pass)
* * * * * * Rejected (Pass)
every day Rejected (Pass)
Code Implementation Generator
// JavaScript / TypeScript (ES6+)
const pattern = /^(?:\*(?:\/[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})$/;
const text = "0 0 * * *";

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 5 whitespace-separated fields supporting asterisks, ranges, step values, and names. Each component of the regular expression serves a distinct syntactical purpose as mapped below:

Token PatternName / ComponentFunction & Rule
Field 1Minutes0-59, *, */5, etc.
Field 2Hours0-23, *, 12-18, etc.
Field 3Day of Month1-31, *.
Field 4Month1-12, JAN-DEC, *.
Field 5Day of Week0-6 (Sun-Sat), MON-FRI, *.

Frequently Asked Questions

Does this match 6-field Quartz cron expressions?
This is for the standard 5-field Unix crontab. Quartz includes a 6th field for seconds.
Browse All 40 Patterns