- function strip_tags(strhtml, allowedTags)
- dim objRegExp, strOutput
- set objRegExp = new regexp
- strOutput = strHTML
- allowedTags = "," & lcase(replace(allowedTags, " ", "")) & ","
- objRegExp.IgnoreCase = true
- objRegExp.Global = true
- objRegExp.MultiLine = true
- objRegExp.Pattern = "<(.|\\n)+?>"
- set matches = objRegExp.execute(strHTML)
- objRegExp.Pattern = "<(/?)(\\w+)[^>]*>"
- for each match in matches
- tagName = objRegExp.Replace(match.value, "$2")
- if instr(allowedTags, "," & lcase(tagName) & ",") = 0 then
- strOutput = replace(strOutput, match.value, "")
- end if
- next
- strip_tags = strOutput
- set objRegExp = nothing
- end function
- //该片段来自于http://www.codesnippet.cn/detail/121020136376.html
来源: http://www.codesnippet.cn/detail/121020136376.html