Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove   in coldfusion

I have var called htmlcode:

  <table width="600" align="center" cellspacing="0" cellpadding="0">
        <tbody>
            <tr>
             <td colspan="3">&nbsp;</td>
            </tr>
            <tr>
             <td colspan="3"><img width="600" height="60" alt="" src="nieuwsbrief_banner.gif</td>
            </tr>
            <tr>
             <td colspan="3">&nbsp;</td>
            </tr>
     </tbody>
   </table>

I want to remove all occurrences of &nbsp;. I am able to replace other characters in a string, but can't seem to replace &nbsp; into an empty string (""). I did this:

<cfset htmlcode = Replace(htmlcode, "&nbsp;", "", "all")>

I also tried replacing nbsp; (without the & in the beginning). The result was that all &nbsp; were changed into &amp;. I then tried <cfset htmlcode = ReplaceNoCase(htmlcode, "&amp;", "", "all")> but this didn't remove any occurrences of &amp;.

What should do?

like image 590
nicemister Avatar asked Jan 26 '26 23:01

nicemister


1 Answers

To strip &nbsp you need to search for chr code 160.

<cfset htmlcode = Replace(htmlcode, chr(160), "", "all")>

https://web.archive.org/web/20180305075110/http://www.cjboco.com/blog.cfm/post/table-of-ascii-characters-and-symbols-for-coldfusion

like image 95
Billy Avatar answered Jan 29 '26 11:01

Billy