Using RIGHT, LEFT, and Replace, and getting really strange results! Help!
Hi all -
I need some help with this one. I'm writing a script that pretty much parses out the header and footer of a saved HTML document, so I only have the middle of it (its a quote file), and then resaves it as a new file. The header parsing (left) works perfectly, but when I get to the footer (right), it rips out everything EXCEPT for the header for some reason! So I end up getting a file that is more or less the header and the footer, but not the meat of the quote file.
Here's my code:
<!---read file --->
<cffile action="read" file="#filestoragelocation#/#cffile.serverFile#" variable="quotecontent">
<!---remove header --->
<cffile action="read" file="#templatelocation#/remove1.html" variable="bannerold">
<!---add new header --->
<cffile action="read" file="#templatelocation#/add1-1.html" variable="bannernew">
<!---replace data --->
<cfset quoteedit=Replace(quotecontent, LEFT(quotecontent,find(bannerold,quotecontent)), bannernew)>
<!--bannerdone--->
<!---update footer --->
<cffile action="read" file="#templatelocation#/remove2.html" variable="oldfooter">
<cffile action="read" file="#templatelocation#/add2w.html" variable="newfooter">
<cfset quoteedit=Replace(quoteedit, RIGHT(quoteedit,find(oldfooter,quoteedit)), newfooter)>
<!---<cfset quoteedit=Replace(quoteedit, oldfooter, newfooter)>--->
<!---write file --->
<cffile action="write" file="#filestoragelocation#/M#cffile.serverFile#" output="#quoteedit#">
So pretty much what I've done with BannerOld and OldFooter is found a tag in the code that is only in the document once (with the banner, its an image, with the footer, its text ("The terms and conditions of the CO")...and hypothetically, with left, I should be selecting everything up to the image in the banner and replacing it, and with right, I should be selecting everything after the text and replacing it.
For whatever reason, instead, I'm just getting the new banner and the footer in the final document. If I remove the footer code, it works perfectly (with of course, the old footer still being there).
I'm probably just having some dumb oversight here...but some help would be amazing. Thanks as always guys!!
JE
