Oops, meant REMatch(), not REFind(). Use REMatch() and it'll do exactly what
you want. Just be sure to check the length of the returned array before
using it.

--- Ben


-----Original Message-----
From: Monique Boea [mailto:moniqueb...@gmail.com] 
Sent: Wednesday, January 26, 2011 2:02 PM
To: cf-talk
Subject: Re: Extracting a date from a string


This give me the value of 32

<cfset string="Department Summary by Employee 10/27/2010 - 10/27/2010">
<cfset dates=REFind("[0-1][0-9]/[0-3][0-9]/[0-9]{4}", string)>
<cfoutput>#dates#</cfoutput>



On Wed, Jan 26, 2011 at 1:54 PM, Ben Forta <b...@forta.com> wrote:

>
> Assuming that the dates are always in mm/dd/yyyy format, I'd use a 
> regular expression, something like this:
>
> <cfset string="*Department Summary by Employee 10/27/2010 - 
> 10/27/2010*"> <cfset dates=REFind("[0-1][0-9]/[0-3][0-9]/[0-9]{4}", 
> string)>
>
> <disclaimer>
> Code written on the fly with no testing ;-) </disclaimer>
>
> Dates will then be an array, and in your example dates[1] will be the 
> start date and dates[2] the second date.
>
> --- Ben
>
>
> -----Original Message-----
> From: Monique Boea [mailto:moniqueb...@gmail.com]
> Sent: Wednesday, January 26, 2011 1:42 PM
> To: cf-talk
> Subject: Extracting a date from a string
>
>
> Hello All.
>
> How would you go about extracting the date from this string:
>
> *Department Summary by Employee 10/27/2010 - 10/27/2010*
>
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341416
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to