Skip to main content
Inspiring
October 30, 2013
Answered

How to do a replace on a sting witch contains an ASCII Char

  • October 30, 2013
  • 1 reply
  • 484 views

Hi All,

I have a string named 'EMAIL_BODY' which contains the following text 'Blah blah &#39 blah blah'  What I want to do is replace &#39 with '

How am I able to do this? as I think I need to escapse the & and # ?

Many thanks,

George

    This topic has been closed for replies.
    Correct answer duncancumming

    Well if you're using the # in CFML you'll most likely need to escape references to it by using ## instead.

    <cfset EMAIL_BODY = "Blah blah &##39 blah blah">

    <cfset newBODY = replace(EMAIL_BODY, "&##39", "&##39;", "ALL")>

    <cfdump var="#variables#">

    1 reply

    duncancummingCorrect answer
    Participating Frequently
    October 30, 2013

    Well if you're using the # in CFML you'll most likely need to escape references to it by using ## instead.

    <cfset EMAIL_BODY = "Blah blah &##39 blah blah">

    <cfset newBODY = replace(EMAIL_BODY, "&##39", "&##39;", "ALL")>

    <cfdump var="#variables#">