Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: regular expression help

by ChrisR (Hermit)
on Jul 26, 2005 at 20:38 UTC ( [id://478356]=note: print w/replies, xml ) Need Help??


in reply to regular expression help

There are many ways to do it but here is a pretty simple and self explanatory one:
use strict; use warnings; use Date::Calc qw(check_date); my $date = "9999/12/11"; my($year,$month,$day) = $date =~ /(\d+)\/(\d+)\/(\d+)/; print "$year/$month/$day is "; if(check_date($year,$month,$day) && $year >=1753 && $year <= 9999) { print "valid"; } else { print "not valid\n"; }
I don't think you are going to be able to do a complete validation using just a regex.

Chris

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-03-28 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found