In javascript, one of the popular regex is to strip out HTML tags from the text. The code for that is
String.prototype.stripHTML = function () {
var reTag = /<(?:.|\s)*?>/g;
return this.replace(reTag, "");
};
If you try this on "<b>This would be bold</b>".stripHTML()
, then it outputs as "This would be bold"
. Shouldn't it output as ""
?
Doesn't this regex says that match everything which starts with <
and ends with >
? Why didn't this regex start at <
of <b>
and end at >
of </b>