Crontab intervals preg match

核能气质少年 提交于 2020-01-06 15:27:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!