Here is a start (I am assuming a few things here)
<!--- find what --->
<cfset findtxt = "Last Network Outage">
<!--- the newoutage --->
<cfset newoutage = "Last Network Outage at Rice:30">
<!--- a mock of your file contents --->
<cfset outages="http://sahdsvr1.alltel.com/outages/
Last Network Outage at 05/26/00 11:22:38 AM CST
http://sahdsvr1.alltel.com/
Homepage Link
">
<!--- find the start of the text in the file contents --->
<cfset start_pos = findnocase(findtxt,outages)-1>
<cfif start_pos lte 0><cfabort showerror="Search String Not Found in File"></cfif>
<!--- find the end of line (assumes there will always be one in the contents)--->
<cfset end_pos = refind("[[:space:]]{2,}",outages,start_pos)>
<cfset newoutage = mid(outages,1,start_pos) & newoutage &
mid(outages,end_pos,(len(outages)))>
<!--- a dump of the new outage file --->
<cfoutput>#newoutage#</cfoutput>
-JR
--- Original ---
I have a plain text file that has a link listed on one line and title on the
next. I want to replace a certain section with a variable using CFFILE. Here
is what I have. I am not sure how to find the string and replace it.
Here is an example of the text file ticker.txt:
http://sahdsvr1.alltel.com/outages/
Last Network Outage at 05/26/00 11:22:38 AM CST
http://sahdsvr1.alltel.com/
Homepage Link
I want to find the http://sahdsvr1.alltel.com/outages/ and next line and replace
it with the newoutage variable.
<! --- Read the File --- >
<cffile action="read"
file="d:\www\outages\ticker.txt"
variable="outages">
How do I parse outages to find and replace the lines I want with newoutage?
<! --- Write to the file --- >
<cffile action="append"
file="d:\www\outages\ticker.txt"
addnewline="yes"
output="#newoutage# ">
Please let me know if this is possible.
Thanks,
Grady Milhon
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
-----------------------------------------------
FREE! The World's Best Email Address @email.com
Reserve your name now at http://www.email.com
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.