请问如何清除数据库调用文章的HTML代码?

请问如何清除数据库调用文章的HTML代码?,第1张

你的问题半天估计是要吧html标记去掉是吧?

用正则表达式,我写一个VBScript函数给你。

<%

function clearHTMLCode(art_content)

dim reg

set reg = new RegExp

reg.Pattern = "<[^>]*>"

reg.Global = true

clearHTMLCode = reg.Replace(art_content, "")

end Function

%>

然后调用:

<%=clearHTMLCode(rs("content"))%>

办法如下: 1、在你的网页中加入这段ASP代码:<%Function ClearHtml(Content)

Content=Zxj_ReplaceHtml("[^>]*", "", Content)

Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content)

Content=Zxj_ReplaceHtml(" ","",Content)

Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content)

Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content)

Content=Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content)

Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content)

Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content)

ClearHtml=Content

End FunctionFunction Zxj_ReplaceHtml(patrn, strng,content)

IF IsNull(content) Then

content=""

End IF

Set regEx = New RegExp ' 建立正则表达式。

regEx.Pattern = patrn ' 设置模式。

regEx.IgnoreCase = true ' 设置忽略字符大小写。

regEx.Global = True ' 设置全局可用性。

Zxj_ReplaceHtml=regEx.Replace(content,strng) ' 执行正则匹配

End Function%>

2、然后将"&left(rs("Content"),100)&"替换成"&left(ClearHtml(rs("Content")),100)&"


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/9902238.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-03
下一篇 2023-05-03

发表评论

登录后才能评论

评论列表(0条)

保存