问题
Purpose: Trusted user puts up a crontab line, give advice when then syntax is wrong
I got this one which seems to work well:
/^\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+\S+\s+.+\S*$/
I want to improve (learning purpose) and tried to reduce the \S+\s
:
/^\s*[(\S+)\s+]{6}.+\S*$/
When you look at typical crontab lines, all its values are seperated by (any amount of) 6 whitespace characters.
2-20/2 10,20 /3 * * user very -long -cryptic > comand
^\s* \S+ \s+ \S+ \s+ \S+ \s+ \S+\s+\S+\s+ \S* $
What's wrong with the short pattern?
来源:https://stackoverflow.com/questions/24541489/crontab-intervals-preg-match