Regular Expressions 101

Community Patterns

Cron Job Regular Expression for JavaScript / ECMAScript


Regular Expression
ECMAScript (JavaScript)

^(((\d+,)+\d+|((\d+|[*])[/]\d+|((JAN|FEB|APR|MA[RY]|JU[LN]|AUG|SEP|OCT|NOV|DEC)(-(JAN|FEB|APR|MA[RY]|JU[LN]|AUG|SEP|OCT|NOV|DEC))?))|(\d+-\d+)|\d+(-\d+)?[/]\d+(-\d+)?|\d+|[*]|(MON|TUE|WED|THU|FRI|SAT|SUN)(-(MON|TUE|WED|THU|FRI|SAT|SUN))?) ?){5}$


Simple pattern for validating Cron Job descriptors in your JavaScript / TypeScript / ECMAScript projects. Includes support for date ranges, day ranges, digit ranges, divisors... all of the things you'd expect to encounter in possible Cron values.

Submitted by Nicholas Berlette ( - 10 months ago