RegEx for a date

Rob Cozens rcozens at pon.net
Sun Dec 22 11:23:48 EST 2002


>Here's what worked for me (verification on one line only):
>
>function CheckDate pDateToCheck
>   if
>matchText(pDateToCheck,"(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/([0-9][0-9]
>[0-9][0-9])") is true then
>     return pDateToCheck
>   else
>     return "Bad date"
>   end if
>end CheckDate

Ken, Yeves, et al:

I'm not a regEx user, but doesn't the above accept as valid dates input like:

* 30/02/2002   (Feb 30)
* 31/04/2002   (April 31)
* 29/02/2002   (Feb 29 on non leap years)

etc.?

The Serendipity Library validDate function will correctly validate 
any date as correct or incorrect based on the system date format: 
<http://www.oenolog.com/ftp/serendipity_downloader.htm>.
-- 

Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)



More information about the use-livecode mailing list