宁波的装修公司排名榜:ASP问题,在线等

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 10:34:23
我现在有一个数据,。是从数据库里读出来的,里面保存的是一段HTML代码。我要把HTML的元素去掉,只要里面的文字,
我应该怎么做
最好能给我个函数

Function TextWithoutHTML(strData)
Dim i,j,strResult
For i = 1 To Len(strData)
If Mid(strData,i,1) = "<" Then
j = InStr(i,strData,">")
i = j '跳过 HTML 标签
Else
strResult = strResult & Mid(strData,i,1)
End If
Next
TextWithoutHTML = strResult
End Function

去掉所有HTML标记
Function FilterHTML(str,strlen)
Dim re
Set re=new RegExp
re.IgnoreCase =True
re.Global=True
re.Pattern="<(.[^>]*)>"
str=re.Replace(str,"")
set re=Nothing
Dim l,t,c,i
l=Len(str)
t=0
For i=1 to l
c=Abs(Asc(Mid(str,i,1)))
If c>255 Then
t=t+2
Else
t=t+1
End If
If t>=strlen Then
cutStr=left(str,i)&"..."
Exit For
Else
cutStr=str
End If
Next
cutStr=Replace(cutStr,chr(10),"")
cutStr=Replace(cutStr,chr(13),"")
End Function