search a date

Yves Coppé yvescoppe at skynet.be
Mon Aug 5 16:00:01 EDT 2002


>
>-- DD/MM/YY format
>function mi_searchDate textToSearch
>   local theDay, TheMonth, TheYear -- this is neccesary
>   put empty into tresult
>   repeat for each line theLine in textToSearch
>     if matchtext(theLine,
>"(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[12])/([0-9][0-9])", theDay, TheMonth,
>TheYear) is true then
>       put theLine & cr after tresult
>     end if
>   end repeat
>   delete last char of tresult
>   return tresult
>end mi_searchDate
>
>This avoids 32/05/02 as a valid date, but doesn't take care of leap years and
>real number of days in a month (januari : 31, february 28 or 29, ...)
>



Jan,

I've found the bug in your code :

for the month search
replace
(0[1-9]|1[12])
by
(0[1-9]|1[0-2])

and then it works fine.
Thank you
-- 
Greetings.

Yves COPPE

Email : yvescoppe at skynet.be



More information about the Use-livecode mailing list