Search code examples
coldfusioncoldfusion-10

How to use Replace() to replace HTML encoded characters in a string


I have some HTML encoded content which I'm placing in a meta tag. I need to replace the line breaks in it which is represented in HTML encoded text as <br />.

I thought I could do this:

#Replace(rsResult.Description, '<br />', '', 'ALL')#

But it keeps throwing an error. The HTML encoded part that I want to remove is whats causing the issue. I don't know why CF can't treat that part as the text to remove from the string.

How could I do this successfully?


Solution

  • You need to escape # character. So your code should be like #Replace(rsResult.Description, '<br &##x2f;>', '', 'ALL')#