Skip to content
Tokenizing a Cron Expression
step 1/5

Reading — step 1 of 5

Read

~1 min readCron Expression Parser

Tokenizing a Cron Expression

A standard cron expression is 5 whitespace-separated fields:

*/15  9-17  *  *  1-5      # Every 15 min, 9am-5pm, weekdays
0     0    1  *  *         # Midnight on the 1st of every month
30    14   *  *  0         # 2:30pm on Sundays
FieldMeaningRange
1minute0-59
2hour0-23
3day-of-month1-31
4month1-12 (or JAN-DEC)
5day-of-week0-6 (or SUN-SAT, 0=Sunday)

Tokenization is the first step. You split on whitespace, validate the field count, and map textual aliases (JAN -> 1, MON -> 1, etc.). Special values like @hourly, @daily, @weekly should expand to their canonical 5-field form before tokenizing.

Your job: read a cron string and output the 5 normalized field strings, one per line.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…