Answer the question
In order to leave comments, you need to log in
How to change regExp, add whiteAttr?
String.prototype.sanitizeHTML=function (white,black) {
if (!white) white="b|i|p|br";
if (!black) black="script|object|embed";
var e=new RegExp("(<("+black+")[^>]*>.*</\\2>|(?!<[/]?("+white+")(\\s[^<]*>|[/]>|>))<[^<>]*>|(?!<[^<>\\s]+)\\s[^</>]+(?=[/>]))", "gi");
return this.replace(e,"");
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question