Nodejs HTML Strip stripHtml()

Here you can find the source of stripHtml()

Method Source Code

// Requirement 6/*from  w ww .ja v  a  2  s  . c  om*/
String.prototype.stripHtml = function () {
  // Sandbox http://www.regexpal.com/?fam=96086
  // Modifiers used g=global m=multiline
  return this.replace(/<(?:.|\n)*?>/gm, '');
};

Related

  1. stripHTML()
    String.prototype.stripHTML = function(){
      var re = new RegExp("(<([^>]+)>)", "ig");
      var str = this.replace(re, "");
      var amps = ["&nbsp;", "&amp;", "&quot;"];
      var replaceAmps =[" ", "&", '"'];
      for(var x=0;x<amps.length;x++){
        str = str.replace(amps[x], replaceAmps[x]);
      re = new RegExp("(&(.*?);)", "ig");
    ...
    
  2. stripHTMLEntities()
    String.prototype.stripHTMLEntities = function() {
      var el = document.createElement("div");
      var html = this.replace(/<img/g, '<x-img');
      el.innerHTML = html;
      return el.innerText;
    
  3. stripHtml()
    String.prototype.stripHtml = function() {
       var tmp = document.createElement("DIV");
       tmp.innerHTML = this;
       return tmp.textContent || tmp.innerText || "";
    };
    
  4. stripHtml()
    String.prototype.stripHtml = function () {
        var _self = this.replace(/(<([^>]+)>)/ig, '');
        return _self;
    
  5. stripHtml()
    String.prototype.stripHtml = function() {
      return this.replace(/<[^>]+>/g, "");
    };
    console.assert("<p>Shoplifters of the World <em>Unite</em>!</p>".stripHtml() == "Shoplifters of the World Unite!");
    console.assert("1 &lt; 2".stripHtml() == "1 &lt; 2");
    
  6. stripHtml()
    String.prototype.stripHtml = function () {
      "use strict";
      var htmlRegex = /(<([^>]+)>)/ig;
      return this.replace(htmlRegex, '');
    };
    
  7. stripHtml()
    ?
    String.prototype.stripHtml = function () {
        return this.replace(new RegExp(/<[^>]+>/g), "");
    };
    
  8. stripTags()
    String.prototype.stripTags = function()
        return this.replace(/<\/?[^>]+>/gi, '');
    };
    
  9. stripTags()
    String.prototype.stripTags = function () {
      return this.replace(/(<([^>]+)>)/ig, "");
    };