VB去除HTML标签函数

VB使用正则表达式实现去除HTML标签函数,适用于网抓。

Function nohtml(str As String) As String

    Dim re

    Set re = CreateObject("VBScript.RegExp")

    re.IgnoreCase = True

    re.Global = True

    re.Pattern = "(\<.[^\<]*\>)"

    str = re.Replace(str, "")

    re.Pattern = "(\<\/[^\<]*\>)"

    str = re.Replace(str, "")'去除html标签

    str = Replace(str, Chr(10), "")'去除换行

    str = Replace(str, Chr(13), "")'去除回车

    nohtml = str

    Set re = Nothing

End Function

你可能感兴趣的:(VB去除HTML标签函数)