Regular expression to find the date
Thierry Douez
th.douez at gmail.com
Thu Jan 5 12:07:18 EST 2012
2012/1/5 paolo mazza <mazzapaoloitaly at gmail.com>
> Thank you Thierry,
> your regular expression works. It was very kind of you.
> All the best
>
> Paolo
>
Hi again Paolo,
Just for fun...
Look at this new Reg exp. below
and see how it matches more precisely dates...
felice anno nuovo !
Thierry
on mouseUp
-- Bad:
put "sfgsfg 35/01/2011 t trtr" into aString
put "sfgsfg 5/0/2011 t trtr" into aString
put "sfgsfg 5/10/1011 t trtr" into aString
-- Ok:
put "sfgsfg 05/01/2011 t trtr" into aString
put "sfgsfg 05-01-2011 t trtr" into aString
put "sfgsfg 05.01.2011 t trtr" into aString
-- put "((\d{2}|\d)/(\d{2}|\d)/(\d{4}|\d{2}))" into myRegEx
put "((0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.](19|20)\d\d)"
into myRegEx
put matchText( aString, myRegEx, theDate) into rslt1
put matchChunk( aString, myRegEx, pos1, pos2) into rslt2
get format( "rslt1: %s \nrslt2: %s \nDate: %s pos1: %s, pos2:
%s\n\n", \
rslt1, rslt2, theDate, pos1, pos2 )
put IT
end mouseUp
More information about the use-livecode
mailing list