Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: ultimate date check regexp

by borisz (Canon)
on Oct 30, 2006 at 09:29 UTC ( #581237=note: print w/ replies, xml ) Need Help??


in reply to ultimate date check regexp

Yes there is, just use the output of the script. true for all valid dates from 1900 .. 2100. I use it in all my scripts!

use Regexp::Assemble; use Date::Calc; my $re = Regexp::Assemble->new; for my $y ( 1900 .. 2100 ) { for my $m ( 1 .. 12 ) { for my $d ( 1 .. 31 ) { if ( Date::Calc::check_date( $y, $m, $d ) ) { $re->add( sprintf( "^%4d.%02d\.%02d\$", $y, $m, $d ) ); } } } } print $re;
Boris


Comment on Re: ultimate date check regexp
Download Code
Re^2: ultimate date check regexp
by davorg (Chancellor) on Oct 30, 2006 at 09:35 UTC

    It seems a little counterproductive to call Date::Calc::check_date almost 75,000 times in order to create that regular expression. Unless you're planning to process more than 75,000 records then it would be more efficient to just call Date::Calc::check_date once for each date you want to check.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Hey, thats more a joke, but Im the only one that does it with a regexp. And I call the script only once and put the resulting regexp into the script. If I need to do it with a regexp.
      Boris

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2015-07-03 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (51 votes), past polls