You can also treat the entire file as a "list" that is delimited by
carriage returns/line feeds:

Untested code:

<cfoutput>
<cfloop list="#file#" index="thisLine" delimiters="#chr(13)##chr(10)#"> 
  <cfif findNoCase("To:", thisLine)>
    <p>#thisLine#</p>
  </cfif>
</cfloop>
<cfoutput>

M!ke

-----Original Message-----
From: Scott Stroz [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 31, 2005 6:44 AM
To: CF-Talk
Subject: Re: locating a substring within a string

Try this:

<cfset l_text = "from: me
to: you
msg: Hello there
to:me
" />

<cfset l_index = REFindNoCase("to:.*?(?=[\r]?\n)",l_text,1,true) />

<cfset l_pos = l_index.pos[1] />
<cfset l_len = l_index.len[1] />

<cfset l_to = Mid(l_text,l_pos,l_len) />

<cfdump var="#l_to#" />



On 10/31/05, Dave Ashworth <[EMAIL PROTECTED]> wrote:
>
> I am using CFdirectory and CFfile to read the contents of a collection

> of ..msg files within a directory
>
> I wish to find the first instance of "To:" within the file and then 
> return that whole line up to the Chr(10) at the end of the line so I 
> can do some work with the address the msg was sent to
>
> is this done with regular expressions (which I know little about) or 
> can this be done with a series of CF functions?
>
> Thanks
> Dave

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:222713
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to