asp 过滤html代码

来源:百度知道 编辑:UC知道 时间:2024/05/09 04:36:31
下面这段代码是取content中的前88个字

<%
if len((xm1("Content")))>88 then
response.write trim(left((xm1("Content")),89))
else
response.write trim((xm1("Content")))
end if
%>

请问 怎么将这88个字中HTML代码过滤掉

思想:建一个guolv.asp 用来放函数 然后include进来

请问该如何写代码啊 在线等 分全部奉献

用正则表达式:

Function filtscript(strHTML)
Dim objRegExp, strOutput
Set objRegExp = New Regexp
strOutput=strHTML
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<[^>]*>"
strOutput = objRegExp.Replace(strOutput, "")
objRegExp.Pattern = "<\/[^>]*>"
strOutput = objRegExp.Replace(strOutput, "")
strOutput = replace(strOutput, "javascript:", "javascript :")
filtscript = strOutput
Set objRegExp = Nothing
End Function

整个程序的作用是过滤所有web标记,留下web标记以外的字符。