macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: how to use REFind

Subject: Re: how to use REFind
From: Adam Cameron <adam_junk@xxxxxxxxxxx>
Date: Mon, 28 Jul 2008 11:32:54 +0100
Newsgroups: macromedia.coldfusion.cfml_general_discussion

> Hi,
> 
>  I did something like this:
> 
>  <cfset strDate = "#now()#">
> 
>  <cfset strDateGet = REFind("{ts 
> '[1234567890][1234567890][1234567890][1234567890]-[1234567890][1234567890]-[1234
> 567890][1234567890] 
> [1234567890][1234567890]:[1234567890][1234567890]:[1234567890][1234567890]'}",st
> rDate)>
> 
> 
>  and it worked. thanks.

Are you really wanting to match that pattern, do you you want to confirm
the string is parseable as a timestamp?

Your regex would accept an awful lot of combinations that pass the test for
that pattern but are not time stamps.

eg:

{ts '0000-99-88 77:66:00'} 

It would also pass as true for:
"any old nonsense before the match {ts '2008-07-28 15:10:50'} and then some
other stuff here too".  The reFind() would return a match there.  Probably
not what you want.


You can also shorten some of your groups:

[1234567890] is the same as [0-9] or \d

And one can express series of the same match with curly-brace notation.
Instead of the cumbersome:

[1234567890][1234567890][1234567890][1234567890]

One could have:

\d{4}

-- 
Adam

<Prev in Thread] Current Thread [Next in Thread>