Created
March 15, 2023 23:38
-
-
Save tuto1902/fc10077c41ca8d2f699e00b641aa1627 to your computer and use it in GitHub Desktop.
Validate a Cron expression using regex
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 | |
if (!preg_match('/^(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)\s+(\*|[0-9,\-\/\*]+)$/', $cronExpression)) { | |
// Invalid expression | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment