• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 250
  • Last Modified:

Help on Regular Expression for Cronjob testing

I need a small test for Cronjob entries...

things like */5 can be ignored

this works...

((\*|(\d(\d)?([,\-]\d(\d)?)*))\s){4}(\*|(\d(\d)?([,\-]\d(\d)?)*))$

i would appreciate any comments
(i am neither an expert in perl nor in regex ....i think in the perl topic i can find the most regex gurus)

so please let me know if this is good

greetz andy
0
AndyWHV
Asked:
AndyWHV
1 Solution
 
ozoCommented:
/^\s*\w+\s*=\s*.*/ || /\s*#.*/ || /^\s*\@(reboot|yearly|annually|monthly|weekly|daily|midnight|hourly)\s+.*/  ||
/^\s*((\*|d\d?([-,]\d\d?)*)(\/\d\d?)?\s+){3}
((\*|1?\d([-,]1?\d)*)(\/\d\d?)|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s+
((\*|[0-7]([-,][0-7])*)(\/\d\d?)|sun|mon|tue|wed|thu|fri|sat|sun)\s+
.*/xi
0
 
AndyWHVAuthor Commented:
i need the time only (no command...) so the expression may end when all the time is specified...
i modified yours a bit because i experienced errors on months and weekdays with my tests
(\/\d\d?) here should follow always a ? ....like you did in minutes,hours and days, right ?

 /^\s*\w+\s*=\s*.*/ || /\s*#.*/ || /^\s*\@(reboot|yearly|annually|monthly|weekly|daily|midnight|hourly)\s+.*/  ||
^((\*|\d\d?([-,]\d\d?)*)(\/\d\d?)?\s+){3}
((\*|1?\d([-,]1?\d)*)(\/\d\d?)?|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s+
((\*|[0-7]([-,][0-7])*)(\/\d\d?)?|sun|mon|tue|wed|thu|fri|sat|sun)$/xi

thank you for this amazing help :-)

now it seems pretty good
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now