Strip HTML Tags
File
striptags.vbs (1 views)
Attached is a simple function to strip specific tags from HTML using the Regexp object.
Syntax:
strippedHTML=stripTags(HTML, tag)
HTML: an HTML string.
tag: the name of the tag you want removed from the HTML.
The function will return the HTML without the given tags.
wscript.echo stripTags("<" & "script>MyScript<" & "/script>","script")
Function stripTags(strHTML,strTag)
'Strips the HTML tags from strHTML
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "</?(" & strTag & ")>"
'Replace all HTML tag matches with the empty string
strOutput = objRegExp.Replace(strHTML, "")
stripTags = strOutput 'Return the value of strOutput
Set objRegExp = Nothing
End Function