PHP has a great function called 'strip_tags'. You pass it a string of HTML, and it removes all formatting and tags, and returns only the text portion. Here's the equivalent in ASP, using regular expressions to do the finding and replacing of HTML tags.
'====
Function stripTags( strToStrip )
'====
Dim objRegExp
strToStrip = Trim( strToStrip & "" )
If Len( strToStrip ) > 0 Then
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern= "<[^>]+>"
strToStrip = objRegExp.Replace(strToStrip, "")
Set objRegExp = Nothing
End If
StripHTMLTags = strToStrip
End Function
Sign up for our daily email newsletter:
You must log in to post a comment.