Copy codeThe Code is as follows: Function RemoveHTML (strHTML) 'filters HTML code. The functions include filtering CSS and JS Code.
StrHtml = Replace (StrHtml, vbCrLf ,"")
StrHtml = Replace (StrHtml, Chr (13) & Chr (10 ),"")
StrHtml = Replace (StrHtml, Chr (13 ),"")
StrHtml = Replace (StrHtml, Chr (10 ),"")
StrHtml = Replace (StrHtml ,"","")
StrHtml = Replace (StrHtml ,"","")
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
ObjRegExp. IgnoreCase = True
ObjRegExp. Global = True
'Take the closed <>
ObjRegExp. Pattern = "<style (. + ?) /Style>"
'For matching
Set Matches = objRegExp. Execute (strHTML)
'Traverse the matching set and replace the matched items.
For Each Match in Matches
StrHtml = Replace (strHTML, Match. Value ,"")
Next
'Take the closed <>
ObjRegExp. Pattern = "<script (. + ?) /Script>"
'For matching
Set Matches = objRegExp. Execute (strHTML)
'Traverse the matching set and replace the matched items.
For Each Match in Matches
StrHtml = Replace (strHTML, Match. Value ,"")
Next
'Take the closed <>
ObjRegExp. Pattern = "<. +?> "
'For matching
Set Matches = objRegExp. Execute (strHTML)
'Traverse the matching set and replace the matched items.
For Each Match in Matches
StrHtml = Replace (strHTML, Match. Value ,"")
Next
RemoveHTML = strHTML
Set objRegExp = Nothing
End Function