去掉 <HTML> 标记

asp函数

2008-05-27 17:15

Public Function RemoveHTML(strHTML)
    Dim nPos1
    Dim nPos2
    nPos1 = InStr(strHTML, "<")
    Do While nPos1>0
        nPos2 = InStr(nPos1+1, strHTML, ">")
        If nPos2>0 Then
            strHTML = Left(strHTML, nPos1 - 1) & Mid(strHTML, nPos2 + 1)
        Else
            Exit Do
        End If
        nPos1 = InStr(strHTML, "<")
    Loop
    RemoveHTML = strHTML
End Function

'-------------------------------------------------
Public Function RemoveHTML(strHTML)
    Dim nPos1
    Dim nPos2
    nPos1 = InStr(strHTML, "<")   '如果有<
    Do While nPos1>0
        nPos2 = InStr(nPos1+1, strHTML, ">")     '查找第一次出现的位置 >
        If nPos2>0 Then          '如果没有了 退出函数
   strHTML = Left(strHTML, nPos1 - 1) & Mid(strHTML, nPos2 + 1)   '截取<前的字符 连接 >之后的字符
        Else  
            Exit Do '如果没有了 退出函数
        End If
        nPos1 = InStr(strHTML, "<") '再次查找<的位置
    Loop
    RemoveHTML = strHTML
End Function

----------------------------------------------------------------------------

Function LoseHtml(ContentStr)
Dim ClsTempLoseStr,regEx
ClsTempLoseStr = Cstr(ContentStr)
Set regEx = New RegExp
regEx.Pattern = "<\/*[^<>]*>"
regEx.IgnoreCase = True
regEx.Global = True
ClsTempLoseStr = regEx.Replace(ClsTempLoseStr,"")
LoseHtml = ClsTempLoseStr
End function