RegEx for a date

Ken Ray kray at sonsothunder.com
Fri Dec 20 17:04:01 EST 2002


Yves,

A couple of things... first, you are missing the key function call to
"matchText" in your regex call; secondly, you don't need to provide
additional variables for theDay, theMonth and theYear unless you are
planning on doing something with them later on (i.e. you don't need them
just for verification); and finally, you are exiting the repeat loop as soon
as you find a good date (I'm not sure if this is what you want). Your
original post said you just wanted to check to see if a line of data is in
the right format, so I removed the repeat loop (you can put it back in if
you're checking a list of dates).

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

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: "Yves Coppé" <yvescoppe at skynet.be>
To: <use-revolution at lists.runrev.com>
Sent: Friday, December 20, 2002 3:35 PM
Subject: RegEx for a date


> Hi,
>
>
> I want to check if a line of a data is a date in European format :
DD/MM/YYYY
>
>
> so I write
>
>
>   local theDay, TheMonth, TheYear
>
>   repeat for each line theLine in uneAnalyse
>            if
>
(theLine,"(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/([0-9][0-9][0-9][0-9])",t
heDay,TheMonth,TheYear)
> is true then
>               put theLine into tDate
>              exit repeat
>            end if
>   end repeat
>
>
> but it doesn't work...
>
> Can someone help me please ???
>
> I think I write wrong for the "year" variable.
>
> Thanks.
> --
> Greetings.
>
> Yves COPPE
>
> Email : yvescoppe at skynet.be
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list