3 Replies Latest reply on Nov 27, 2014 12:48 AM by BKBK

    replace quotes?


      Hello I'm on Coldfusion 10 and I'm trying to figure out how to replace quotes ("). So far I tried this:


      <cfset Session.Artist1 = Replace(Session.Artist1,"&quot;","&quot;",'ALL') >


      That does nothing, I then tried this:


      <cfset Session.Artist1 = Replace(Session.Artist1,"&#34","&quot;",'ALL') >


      That errors out CF. I'll get this:


      Error Occurred While Processing Request

      Invalid construct: Either argument or name is missing.


      So is there anything that would work in CF and in SQL for " (quotes)? I having people use the HTML &quot;, but that also shows up in SQL as the coding. I would like it to work in CF and in SQL as just ", but can't figure out how. Any help would be great.



        • 1. Re: replace quotes?
          BKBK Adobe Community Professional & MVP

          Chr(34) is neat for the double quote. So try


          <cfset Session.Artist1 = Replace(Session.Artist1, chr(34), "&quot;", "all") >


          You could also be creative with single quotes, like this


          <cfset Session.Artist1 = Replace(Session.Artist1, '"', '&quot;', 'all') >

          • 2. Re: replace quotes?
            taunnt Level 1

            I tried this and it doesn't do anything:


            <cfset Session.Artist1 = Replace(Session.Artist1 , Chr(34),"&quot;",'ALL') >


            What is happening is you can search for 'the "thing"' after you hit return CF will change it to 'the'. So it will ignore any characters after the ".

            • 3. Re: replace quotes?
              BKBK Adobe Community Professional & MVP

              I get no such complication. When I run the code


              <cfset str='the "thing"'>

              <cfset newStr = replace(str, chr(34),"&quot;","all")>



              I get the result


              the &quot;thing&quot;


              Remember to view the result in the browser's source page.