replace two variable in file content

Posted on 2011-04-21
Last Modified: 2012-06-27
Hello,  I have a file creation script that works great when i only have to replace one variable,  however, i need to replace two variables and can't get the script to work.  I know that what i have now replaces CC with XX.  I have also tried several other tires.  

What i really need is in the file with the variables to have the url="CC" be replaced with the qlist.cid and the xx be replace with  qlist.scndtgry_ID.

if i remove either one of the cc or xx from the replace the one that is left gets the correct nubmer.  i just really need both.  

hopefully this makes sense.

thank you.

here is the code for the creation,
<cfset CC = qList.CID>
 <cfset XX = qList.scndctgry_ID>
<cfset ses_fileContents = replace(ses_fileContents_original, "CC" , "XX", #qList.CID# & #qList.scndctgry_ID#)> 

here is the file with the variables

<cfset url.category = "CC">
<cfset url.secondary = "XX">
<cfinclude template="SubMain.cfm">

Open in new window

Question by:TigerladyBarb
    LVL 19

    Accepted Solution


    try this

    <cfset CC = qList.CID>
     <cfset XX = qList.scndctgry_ID>
    <cfset ses_fileContents = replace(replace(ses_fileContents_original, "CC" , #qList.CID#) ,"XX",#qList.scndctgry_ID#)>

    Author Closing Comment

    Oh my gosh i didn't even think of the double replace.  I tried so many other variations.  finally i can move on.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
    CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now