Here the cron regex :
(((\*)|(([0-9]|[0-5][0-9]))|(((\*|([0-9]|[0-5][0-9]))\/([0-9]|[0-5][0-9])))|(([0-9]|[0-5][0-9])(,([0-9]|[0-5][0-9]))*)|(([0-9]|[0-5][0-9])-([0-9]|[0-5][0-9])(\/([0-9]|[0-5][0-9]))?)) ((\*)|(([0-9]|[0-1][0-9]|2[0-3]))|(((\*|([0-9]|[0-1][0-9]|2[0-3]))\/([0-9]|[0-1][0-9]|2[0-3])))|(([0-9]|[0-1][0-9]|2[0-3])(,([0-9]|[0-1][0-9]|2[0-3]))*)|(([0-9]|[0-1][0-9]|2[0-3])-([0-9]|[0-1][0-9]|2[0-3])(\/([0-9]|[0-1][0-9]|2[0-3]))?)) ((\*)|(([0-9]|[0-1][0-9]|3[0-1]))|(((\*|([0-9]|[0-1][0-9]|3[0-1]))\/([0-9]|[0-1][0-9]|3[0-1])))|(([0-9]|[0-1][0-9]|3[0-1])(,([0-9]|[0-1][0-9]|3[0-1]))*)|(([0-9]|[0-1][0-9]|3[0-1])-([0-9]|[0-1][0-9]|3[0-1])(\/([0-9]|[0-1][0-9]|3[0-1]))?)) ((\*)|(([0-9]|0[0-9]|1[0-2]))|(((\*|([0-9]|0[0-9]|1[0-2]))\/([0-9]|0[0-9]|1[0-2])))|(([0-9]|0[0-9]|1[0-2])(,([0-9]|0[0-9]|1[0-2]))*)|(([0-9]|0[0-9]|1[0-2])-([0-9]|0[0-9]|1[0-2])(\/([0-9]|0[0-9]|1[0-2]))?)) ((\*)|(([0-7]))|(((\*|([0-7]))\/([0-7])))|(([0-7])(,([0-7]))*)|(([0-7])-([0-7])(\/([0-7]))?)))|(@reboot|@yearly|@annually|@monthly|@weekly|@daily|@midnight|@hourly)
- * * * * *
- 0 * * * *
- 0,15,30,45 * * * *
- 0-30 * * * *
- 15-45 * * * *
- 15-45/2 * * * *
- ... same for each fields
- @daily
- @Monthly
-
-
-
- dec SuN
-
-
6 positions
- 1 2 3 4 5 6
Offset values
- 60 2 3 4 5
- 1 24 3 4 5
- 1 2 32 4 5
- 1 2 3 13 5
- 1 2 3 4 7
invalid char & some specials symbols
- 1 2 a 4 5
- 1 2 3 4 5L <- Last Friday of May
- 1 2 3W 4 5 <- the nearest weekday to the 3th of the month
- 1 2 3 4 5#2 <- the second Friday" of a given month
- ? ? * * * * <- i didn't even know it exists
- The cron doesn't manage the 6th & 7th position, btw the classic cron doesn't manage more than 5 parts.
- The symbol ? L W # are not managed
Feel free to improve this regex :=)
Based on : https://en.wikipedia.org/wiki/Cron, Tested on : https://regex101.com/r/cP5tX2/2 Explained on : https://www.debuggex.com/r/ZCSczLBqayVUEQEO