本文主要是介绍asp ClearHtml() 清除HTML,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ClearHtml() 清除HTML
str_left() 截取字数
<%=str_left(ClearHtml(get_field("cms_channel",4,"c_scontent")),200,"...")%>
···
'/* 函数名称:ReplaceHtml ClearHtml
'/* 函数语言:VBScript Language
'/* 作 用:清除文件HTML格式函数
'/* 传递参数:Content (注:需要进行清除的内容)
'/* 函数说明:正则匹配(正则表达式)模式进行数据匹配替换Function ClearHtml(Content)
Content=ReplaceHtml("&#[^>]*;", "", Content)
Content=ReplaceHtml("</?marquee[^>]*>", "", Content)
Content=ReplaceHtml("</?object[^>]*>", "", Content)
Content=ReplaceHtml("</?param[^>]*>", "", Content)
Content=ReplaceHtml("</?embed[^>]*>", "", Content)
Content=ReplaceHtml("</?table[^>]*>", "", Content)
Content=ReplaceHtml(" ","",Content)
Content=ReplaceHtml("</?tr[^>]*>", "", Content)
Content=ReplaceHtml("</?th[^>]*>","",Content)
Content=ReplaceHtml("</?p[^>]*>","",Content)
Content=ReplaceHtml("</?a[^>]*>","",Content)
Content=ReplaceHtml("</?img[^>]*>","",Content)
Content=ReplaceHtml("</?tbody[^>]*>","",Content)
Content=ReplaceHtml("</?li[^>]*>","",Content)
Content=ReplaceHtml("</?span[^>]*>","",Content)
Content=ReplaceHtml("</?div[^>]*>","",Content)
Content=ReplaceHtml("</?th[^>]*>", "", Content)
Content=ReplaceHtml("</?td[^>]*>", "", Content)
Content=ReplaceHtml("</?script[^>]*>", "", Content)
Content=ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content)
Content=ReplaceHtml("on(mouse|exit|error|click|key)", "", Content)
Content=ReplaceHtml("<\\?xml[^>]*>", "", Content)
Content=ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content)
Content=ReplaceHtml("</?font[^>]*>", "", Content)
Content=ReplaceHtml("</?b[^>]*>","",Content)
Content=ReplaceHtml("</?u[^>]*>","",Content)
Content=ReplaceHtml("</?i[^>]*>","",Content)
Content=ReplaceHtml("</?strong[^>]*>","",Content)
ClearHtml=Content
End FunctionFunction ReplaceHtml(patrn, strng,content)
IF IsNull(content) Then
content=""
End IF
Set regEx = New RegExp ' 建立正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = true ' 设置忽略字符大小写。
regEx.Global = True ' 设置全局可用性。
ReplaceHtml=regEx.Replace(content,strng) ' 执行正则匹配
End Function
这篇关于asp ClearHtml() 清除HTML的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!