In perl6.....
#!/usr/bin/pugs use v6; rule minute { <[1..5]>?\d | <[*]> }; rule hour { <[1..2]>?\d | <[*]> }; rule day { 31 | 30 | <[1..2]>?\d | <[*]> } rule month { 1?\d | <[*]> } rule day_of_week { <[0..6]> | <[*]> } rule crontab { <minute> \s+ <hour> \s+ <day> \s+ <month> \s+ <day_of_w +eek> } my $crontab = "0 10 * * *" ~~ /<crontab>/; my $match = $crontab<crontab>; say "Minute: $match<minute>\nHour: $match<hour>\n" ~ "Day: $match<day>\nMonth: $match<month>\n" ~ "Day of Week: $match<day_of_week>";
1;0 eric256@feather:~/tests$ pugs crontab.p6 Minute: 0 Hour: 10 Day: * Month: * Day of Week: *
In reply to Re: simple pattern match ?
by eric256
in thread simple pattern match ?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |