Nodejs HTML Decode htmlDecode()

Here you can find the source of htmlDecode()

Method Source Code

String.prototype.htmlDecode = function() {
   return this.replace(/\&amp\;/g, '\&').replace(/\&gt\;/g, '\>').replace(
         /\&lt\;/g, '\<').replace(/\&quot\;/g, '\'').replace(/\&\#39\;/g,
         '\'');/*from w  w  w.  j  ava2 s.c o m*/
};

Related

  1. htmlDecode(value)
    function htmlDecode(value)
        if(value)
            return $("<div />").html(value).text();
        else
            return '';
    ...
    
  2. htmlDecode()
    String.prototype.htmlDecode = function () {
        var div = document.createElement('div');
        div.innerHTML = this;
        return div.innerText || div.textContent;
    };
    
  3. decodeHtml()
    String.prototype.decodeHtml = function () {
        var string = new String(this);
        string = string.replace(/&lt;/g, "<");
        string = string.replace(/&gt;/g, ">");
        string = string.replace(/&quot;/g,  "\"")
        string = string.replace(/&39;/g,  "'");
        string = string.replace(/&amp;/g, "&");
        return string
    
  4. decodeHtmlEntity()
    String.prototype.decodeHtmlEntity = function(){
        var ta = document.createElement('textarea');
        ta.innerHTML = this;
        return ta.value;
    };