Whenever I have to apply more complex text operations I tend to use regular expressions.
If you want to remove HTML tags from a String, nothing is faster and easier than using regular expressions to do so.
Source Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
' @Author - Alexander Bolte' @ChangeDate - 2014-11-06' @Description - Removing HTML tags from a provided HTML text.' @Param htmlText - a String holding HTML text.' @Remarks - Using a regular expression to remove HTML tags from a provided String.' Regular expression is as follows.' "<([A-Z][A-Z0-9]*)\b[^>]*>|<\/([A-Z][A-Z0-9]*)>"PublicFunctionreplaceHTMLTags(ByValhtmlTextAsString)AsStringDimregExAsNewRegExpConstcHtmlPatternAsString="<([A-Z][A-Z0-9]*)\b[^>]*>|<\/([A-Z][A-Z0-9]*)>"regEx.Global=TrueregEx.IgnoreCase=TrueregEx.pattern=cHtmlPatternhtmlText=regEx.Replace(htmlText,"")replaceHTMLTags=htmlTextEndFunction
Referenced APIs
This code references the following API, which is a VBScript API.