ASP 实用函数- HTML 过滤

2015-01-07 0 575
ASP 实用函数- HTML 过滤
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

遇见资源网 ASP/Basic ASP 实用函数- HTML 过滤 http://www.ox520.com/13365.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务