I want to learn a little more about regular expressions. I thought of a good exercise that will be validating if a cronjob expression is correct or not.
So,thepossiblecombinationsbelowshouldreturntrueaccordingtotheso-calledregularexpression.
*****1-15*/50,30*50,30***1-5
RememberingthatalltheabovenumbersrepresentavalidexpressionofCronjob.
Anotherdetailisthatexpressionmustcontain5"members" separated by space. These members, as exemplified above, should be as depicted in the image.
The expression can be evaluated as:
<minuto><espaço><hora><espaço><dia_do_mês><espaço><mês><espaço><dia_semana>
For those who do not understand how cronjob works here is a small example:
Performs hourly
0 * * * * comando
Runs from hour to hour, from 1 to 5
0 1-5 * * * comando
According to the image above, how could I create a validation for a cronjob expression?
I just need to validate the content regarding the definition of the time that will be executed, I do not need to validate the command that comes after the expression.
Note : I just need logic to learn regex, so any language is valid for the answer.