// C# Cron Validation Regular Expression
// Dash: Minute: Hour: Day: Month: Day of Week:
const string CronValidationRegex = @"^\-$|^(\*|(([0-5]?[0-9]|60)(,([0-5]?[0-9]|60))*)|([0-5]?[0-9]|60)\-([0-5]?[0-9]|60)(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|(([0-9]|1[0-9]|2[0-4])(,([0-9]|1[0-9]|2[0-4]))*)|([0-9]|1[0-9]|2[0-4])\-([0-9]|1[0-9]|2[0-4])(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|(([1-9]|[1-2][0-9]|30|31)(,([1-9]|[1-2][0-9]|30|31))*)|([1-9]|[1-2][0-9]|30|31)\-([1-9]|[1-2][0-9]|30|31)(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|(([1-9]|1[0-2])(,([1-9]|1[0-2]))*)|([1-9]|1[0-2])\-([1-9]|1[0-2])(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|([0-7](,[0-7])*)|[0-7]\-[0-7](\/[0-9]+)?|\*\/[0-9]+)$";
// JavaScript Cron Validation Regular Expression
// Dash: Minute: Hour: Day: Month: Day of Week:
const CronValidationRegex = /^\-$|^(\*|(([0-5]?[0-9]|60)(,([0-5]?[0-9]|60))*)|([0-5]?[0-9]|60)\-([0-5]?[0-9]|60)(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|(([0-9]|1[0-9]|2[0-4])(,([0-9]|1[0-9]|2[0-4]))*)|([0-9]|1[0-9]|2[0-4])\-([0-9]|1[0-9]|2[0-4])(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|(([1-9]|[1-2][0-9]|30|31)(,([1-9]|[1-2][0-9]|30|31))*)|([1-9]|[1-2][0-9]|30|31)\-([1-9]|[1-2][0-9]|30|31)(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|(([1-9]|1[0-2])(,([1-9]|1[0-2]))*)|([1-9]|1[0-2])\-([1-9]|1[0-2])(\/[0-9]+)?|\*\/[0-9]+)\s+(\*|([0-7](,[0-7])*)|[0-7]\-[0-7](\/[0-9]+)?|\*\/[0-9]+)$/;
- "asterick" or "comma separated values" or "start-value dash end-value with optional slash interval" or "asterick with slash interval", e.g.:
*
orvalue1[,valueN]*
orvalue1-value2[/interval]
or*/interval
(\*|(([0-5]?[0-9]|60)(,([0-5]?[0-9]|60))*)|([0-5]?[0-9]|60)\-([0-5]?[0-9]|60)(\/[0-9]+)?|\*\/[0-9]+)
(\*|(([0-9]|1[0-9]|2[0-4])(,([0-9]|1[0-9]|2[0-4]))*)|([0-9]|1[0-9]|2[0-4])\-([0-9]|1[0-9]|2[0-4])(\/[0-9]+)?|\*\/[0-9]+)
(\*|(([1-9]|[1-2][0-9]|30|31)(,([1-9]|[1-2][0-9]|30|31))*)|([1-9]|[1-2][0-9]|30|31)\-([1-9]|[1-2][0-9]|30|31)(\/[0-9]+)?|\*\/[0-9]+)
(\*|(([1-9]|1[0-2])(,([1-9]|1[0-2]))*)|([1-9]|1[0-2])\-([1-9]|1[0-2])(\/[0-9]+)?|\*\/[0-9]+)
(\*|([0-7](,[0-7])*)|[0-7]\-[0-7](\/[0-9]+)?|\*\/[0-9]+)
0,25,59,60 0,12,23,24 1,5,29,30,31 1,5,9,12 0,3,6,7
0-59 0-23 1-31 1-12 0-6
0-59/10 0-23/2 1-31/3 1-12/4 0-6/2
*/10 */2 */3 */4 */2
Note: In this implementation a single dash
-
represents a disabled cron schedule.