search a date

Yves Coppé yvescoppe at skynet.be
Mon Aug 5 09:22:00 EDT 2002


>use-revolution at lists.runrev.com writes:
>>function mi_searchDate textToSearch
>>    local theDate -- this is neccesary
>>    put empty into tresult
>>    repeat for each line theLine in textToSearch
>>      if matchtext(theLine, "([0-9][0-9]/[0-9][0-9]/[0-9][0-9])",
>>theDate ) is true then
>>        put theDate & cr after tresult
>>      end if
>>    end repeat
>>    delete last char of tresult
>>    return tresult
>>end mi_searchDate
>
>
>Maybe there should be some additional tests for day (1-31) and month numbers
>(1-12)
>
>-- 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
>


Oops Jan, there is a bug in your function :

what about :
answer mi_searchDate("29/10/97")

try it with the function of Björnke (see above) : it returns the date
with your code, it returns empty !!

Since I'm not so expert with the matchtext function, I don't know 
where is the error.
Can you fix it ?

Thank you.
-- 
Greetings.

Yves COPPE

Email : yvescoppe at skynet.be



More information about the use-livecode mailing list