Created
February 21, 2010 08:05
-
-
Save istvanp/310203 to your computer and use it in GitHub Desktop.
Cron expression syntax check (excluding special operators except for * and /)
This file contains 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
<?php | |
$cron = "*/5 * * * * *"; | |
$result = preg_match( | |
"/(\*|[0-5]?[0-9]|\*\/[0-9]+)\s+" | |
."(\*|1?[0-9]|2[0-3]|\*\/[0-9]+)\s+" | |
."(\*|[1-2]?[0-9]|3[0-1]|\*\/[0-9]+)\s+" | |
."(\*|[0-9]|1[0-2]|\*\/[0-9]+|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s+" | |
."(\*\/[0-9]+|\*|[0-7]|sun|mon|tue|wed|thu|fri|sat)\s*" | |
."(\*\/[0-9]+|\*|[0-9]+)?/i", $cron, $matches); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment