Nodejs HTML Strip stripTags()

Here you can find the source of stripTags()

Method Source Code

/**/*from  w  ww. j av  a  2  s  .  c o m*/
 * Simple strip tags helper.
 *
 * @returns {string}
 */
String.prototype.stripTags = function() {
    var div = document.createElement("div");

    div.innerHTML = this.br2nl();

    return div.textContent || div.innerText || "";
};

Related

  1. stripHtml()
    String.prototype.stripHtml = function () {
      "use strict";
      var htmlRegex = /(<([^>]+)>)/ig;
      return this.replace(htmlRegex, '');
    };
    
  2. stripHtml()
    ?
    String.prototype.stripHtml = function () {
        return this.replace(new RegExp(/<[^>]+>/g), "");
    };
    
  3. stripTags()
    String.prototype.stripTags = function()
        return this.replace(/<\/?[^>]+>/gi, '');
    };
    
  4. stripTags()
    String.prototype.stripTags = function () {
      return this.replace(/(<([^>]+)>)/ig, "");
    };
    
  5. stripTags()
    String.prototype.stripTags = function(){
      var entity = {
        quot: '"',
        lt: '<',
        gt: '>',
        nbsp: ' '
      };
      return function ( ) {
        return this.replace(/&([^&;]+);/g,
    ...
    
  6. stripTags()
    String.prototype.stripTags = function() {
      return this.replace(/(<([^>]+)>)/ig, '');
    
  7. stripTags()
    String.prototype.stripTags = function () {
           var str = this;
           var pos1 = str.indexOf('<');
        if (pos1 == -1) return str;
        else {
            var pos2 = str.indexOf('>', pos1);
            if (pos2 == -1) return str;
            return (str.substr(0, pos1) + str.substr(pos2+1)).stripTags();
    
  8. striptags()
    String.prototype.striptags = function() {
      return this.replace(/(<.*?>)/g).replace(/undefined/g,'?');