search a date

Jan Decroos jan.decroos at groepvanroey.be
Mon Aug 5 04:12: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

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




More information about the use-livecode mailing list