Solved

Invalid CFML Error when using Replace Function

Posted on 2011-09-30
2
266 Views
Last Modified: 2012-05-12
Hi,

I am using the replace function to clean up some html content.  Some of the text is in quotes and I believe that is why I am getting the error.  Anyway around this?
Thanks in advance!

<cfcomponent>
   
    <cffunction name="createEditorFile1" access="remote" returnType="string">
      <cfargument name="data" type="string" required="true">
         <cfargument name="GroupNo" type="string" required="true">
          <cfargument name="NPSGroupNumber" type="string" required="true">
         <cfargument name="NPSGroupSection" type="string" required="true">
          <cfargument name="BPIDReg" type="string" required="true">

             <cfset cleanData = replace(#cleandata#,"<th class="col1" />","<th class="col1">&nbsp;</th>","all")>
               
      <cfreturn cleanData>
    </cffunction>
   
   
</cfcomponent>
       
0
Comment
Question by:armanbena
2 Comments
 
LVL 10

Expert Comment

by:stu215
ID: 36892658
0
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 36892713

You have nested quotes in your statement...  you cannot enclose quotes within quotes unless they are escaped or different types of quotes

   <cfset cleanData = replace(#cleandata#,"<th class="col1" />","<th class="col1">&nbsp;</th>","all")>

Enclose in single quotes instead (and of course get rid of the useless #s around cleanData)

   <cfset cleanData = replace(cleandata,'<th class="col1" />','<th class="col1">&nbsp;</th>',"all")>
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

23 Experts available now in Live!

Get 1:1 Help Now