Regular Expressions 101

Community Library Entry

1

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}$
/
idu

Description

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 (https://github.com/nberlette) - a year ago