var tag = /<\/?\w+(?:\s+\w+(?:\s*=\s*(?:(?:"(?:\\.|[^"])*")| (?:'(?:\\.|[^'])*')|[^>\s]+))?)*\s*\/?>/gim; var tagName = /^<\/?(\w+)/im; String.prototype.stripHTMLTags = function(tagsToKeep){ if(tagsToKeep) tagsToKeep = tagsToKeep.invoke('toLowerCase'); return this.replace(tag, function(m){ return (tagsToKeep && tagsToKeep.indexOf(m.match(tagName) [1].toLowerCase())!=-1? m: ''); }); };
alert('<a href="javascript:alert(\'>\')">test</a>'.stripHTMLTags()); alert('<a href="javascript:alert(\'>\')">test</a>'.stripTags()); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---