Javascript String stripTags()
var str = "<p><strong><em>PHP Exercises</em></strong></p>"; String.prototype.stripTags = function() { return this.replace(/<\/?[^>]+>/g, ''); }; console.log(str.stripTags());/*from w ww.ja va 2s . c o m*/
//from prototype library String.prototype.stripTags = function() { return this.replace(/<\/?[^>]+>/gi, ''); };
String.prototype.stripTags = function () { return this.replace(/(<([^>]+)>)/ig, ""); }; /**/* www.j a v a2 s . c o m*/ * sprintf-like functionality * replaces {0}, {1}... in a string with arguments passed to a function */ if (!String.prototype.format) { String.prototype.format = function() { var args = arguments; return this.replace(/{(\d+)}/g, function(match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); }; }
String.prototype.stripTags = function () { return this.replace(/\<.*\>/gi, ''); }
String.prototype.striptags = function() { return this.replace(/(<.*?>)/g).replace(/undefined/g,'?'); }
String.prototype.stripTags = function(){ var entity = {/*from ww w . j a v a2 s . c o m*/ quot: '"', lt: '<', gt: '>', nbsp: ' ' }; return function ( ) { return this.replace(/&([^&;]+);/g, function (a, b) { var r = entity[b]; return typeof r === 'string' ? r : a; } ); }; }( );