Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Date Validation using just a regex

by delirium (Chaplain)
on Jul 01, 2004 at 15:52 UTC ( [id://371136]=note: print w/replies, xml ) Need Help??


in reply to Date Validation using just a regex

If you don't mind an expression regex...

while(<>){ chomp; $_ = 'Use YYYY-MM-DD format' unless s/^(\d{4})-(\d\d)-(\d\d)$/ $1<1 || $2<1 || $3<1 ? 'Year, month, and day must be greater than +0' : $2>12 ? 'Month must be less than 13' : $3>31 ? 'Day must be less than 32' : $3==30&&$2==2 ? 'February has less than 30 days' : $3==29 && $2==2 && $1%4!=0 ? 'February only has 29 days in a leap +year' : $3==31 && $2 =~ m!0[2469]|11! ? '30 days hath September, yada yada +..' : $_ /e; print ": $_ :\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://371136]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2025-02-07 02:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (94 votes). Check out past polls.