I'm not sure you'll find a regexp-way to solve this in an accurate way.
You might want to process/validate the entry you get with DateTime::Event::Cron, somehow similar to the following:
#!/usr/bin/perl use strict; use warnings; use DateTime::Event::Cron; my @crontab = ( '*/3 15 1-10 3,4,5 */2', '* * * * 1-4,5-7,11,20', '* * * 1-4,5-7,11,20 *', '* * 1-4,5-7,11,20 * *', '* 1-4,5-7,11,20 * * *', '1-4,5-7,11,20 * * * *', ); my $set; foreach my $line (@crontab) { eval { $set = DateTime::Event::Cron->from_cron( $line ); }; print "$line: ", ($@ ? $@ : 'OK'), "\n"; }
The output of which is
*/3 15 1-10 3,4,5 */2: OK * * * * 1-4,5-7,11,20: Field value (20) out of range (1-7) * * * 1-4,5-7,11,20 *: Field value (20) out of range (1-12) * * 1-4,5-7,11,20 * *: OK * 1-4,5-7,11,20 * * *: OK 1-4,5-7,11,20 * * * *: OK
which might be easier to handle/debug then the output of a regexp check.

Hth.

In reply to Re: simple pattern match ? by Krambambuli
in thread simple pattern match ? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.