Copy codeThe Code is as follows:
'================================================ ==============
'Function name: ScriptHtml
'Use: filter html tags
'Parameter: ConStr ------ string to be filtered
'================================================ ==============
Function ScriptHtml (Byval ConStr, TagName, FType)
Dim Re
Set Re = new RegExp
Re. IgnoreCase = true
Re. Global = True
Select Case FType
Case 1
Re. Pattern = "<" & TagName & "([^>]) *>"
ConStr = Re. Replace (ConStr ,"")
Case 2
Re. Pattern = "<" & TagName & "([^>]) *> .*? </"& TagName &" ([^>]) *>"
ConStr = Re. Replace (ConStr ,"")
Case 3
Re. Pattern = "<" & TagName & "([^>]) *>"
ConStr = Re. Replace (ConStr ,"")
Re. Pattern = "</" & TagName & "([^>]) *>"
ConStr = Re. Replace (ConStr ,"")
End Select
ScriptHtml = ConStr
Set Re = Nothing
End Function
1 content = ScriptHtml (content, "br", 1) 'remove all <br> HTML tags
2 content = ScriptHtml (content, "a", 2) 'remove all <a> </a> and content between the two tags
For example, <a href = www.126.com> www.126.com </a> completes this section.
3 content = ScriptHtml (content, "td", 3) 'remove the <td> and </td> HTML tags
For example, <td> Shi Dafu SA </td> removed <td> </td>, but Shi Dafu SA kept
And so on, filter all other HTML tags out of div objdect or something.