Strip Tags (VBScript)
The following function strips tags from the supplied input string. Set 'tags' argument to blank string - "" - to strip all tags. Use:
' remove spans input = StripTags(input,"span") ' remove b and u input = StripTags(input,"b|u") ' remove all tags input = StripTags(input,"")
Function StripTags(input,tags) ' set 'tags' to empty string to strip all tags If tags = "" Then tags = "[a-zA-Z]+" Dim regEx : Set regEx = New RegExp regEx.IgnoreCase = True regEx.Global = True ' tag to remove (based on http://regexplib.com/REDetails.aspx?regexp_id=211) regEx.Pattern = "</?("+tags+")(\s+\w+=(\w+|""[^""]*""|'[^']*'))*\s*?/?>" StripTags = regEx.Replace(input, "") End Function
Edit (19 May 2005): Fix to regular expression to match multiple spaces before > , i.e. <p  >
Tags: Web Developer Blog, VBScript, VBS
Comments