Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 324
  • Last Modified:

Replacing #

string1 contains a value retrieved from a database table, this is "Don't and Won't" - where ' is the character code for an apostrophe.

I would like to replace the character code with an actual apostrophe

<cfset string2 = replace(string1,"&#039;","'">

So the result will be:

Don't and Won't

Trouble being that Coldfusion doesn't like the # in the replace()

Any ideas?
0
bbowman
Asked:
bbowman
  • 2
1 Solution
 
PE_CF_DEVCommented:
use ##
0
 
PE_CF_DEVCommented:
Doubling up the # sign is like using escapes in other languages. Same thing in SQL if youm want an apostrophie you do '', in coldfusion if you want to use a # sign you do ##..Ment to put this all in one post hit tabthen enter and poof it got submited :-))

So your code would be:

<cfset string2 = replace(string1,"&##039;","'">
0
 
bbowmanAuthor Commented:
Yep, tried that and it didn't work.

Tried it again and it did?!

0

Featured Post

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now