Last active
August 6, 2020 13:46
-
-
Save harshithjv/4f76d9dda00c10e3d5a2 to your computer and use it in GitHub Desktop.
Simpler Python Regex object to validate crontab entry time format string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validate_crontab_time_format_regex = re.compile(\ | |
| r"^{0}\s+{1}\s+{2}\s+{3}\s+{4}$".format(\ | |
| r"(?P<minute>[\d\*]{1,2}([\,\-\/][\d\*]{1,2})*)",\ | |
| r"(?P<hour>[\d\*]{1,2}([\,\-\/][\d\*]{1,2})*)",\ | |
| r"(?P<day>[\d\*]{1,2}([\,\-\/][\d\*]{1,2})*)",\ | |
| r"(?P<month>[\d\*]{1,2}([\,\-\/][\d\*]{1,2})*)",\ | |
| r"(?P<day_of_week>[0-6\*]([\,\-\/][0-6\*])*)" | |
| ) # end of str.format() | |
| ) # end of re.compile() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello they are a probleme for example if the crontab are:
0 7 * * 1,2,3,4,5,8
(validate_crontab_time_format_regex.match("0 7 * * 1,2,3,4,5,8").groupdict())
result:
{'minute': '0', 'hour': '7', 'day': '', 'month': '', 'day_of_week': '1'}