search a date

Yves Coppé yvescoppe at skynet.be
Sat Aug 3 14:03:01 CDT 2002


>on mouseUp
>   local theDate -- this is neccesary
>   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 & return after msg
>     end if
>   end repeat
>end mouseUp
>
>This returns one date per line if there are mor the one date per 
>line, it will report the first one, even when in a line with other 
>text... but it is not a function, so you will have to adjust it a 
>little ;)
>
>hope it solves your needs
>Bjoernke
>

I translate your codee in a function
I works good even with French dates
This is the code

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



Note :

I wrote such a function

repeat for each line L in textToSearch
if L is a date then
put L&cr after tresult
end if
end repeat


But sometimes some lines are returned although they are not a date

with your code, this is correct.


Thank you very much
-- 
Greetings.

Yves COPPE

Email : yvescoppe at skynet.be



More information about the use-livecode mailing list