Stripping HTML from an ASP code and then Trimming It
To start off I would like to say that I have very little experience in dealing with classic ASP. My specialty is HTML and CSS so I'm a little bit lost here. Hopefully someone here can lend me a hand.
My company sells projectors and other AV equipment. I would like to take the product descriptions that appear on the individual product pages and use them in my META tags and Facebook OpenGraph tags.
The product descriptions are saved in our database as text with HTML tags in it. I need these descriptions to load into my HTML as plain text without HTML elements or styling.
Here's what I would like to do: 1. Strip HTML tags from a body of text. 2. Trim that text to a pre-determined length or after a certain amount of sentences.
Here is the ASP tag in my HTML that loads the product description. And here is an example of one of the pages it loads into.
I searched for a code that would help me with removing the HTML tags and I found this piece right here.
Set RegularExpressionObject = New RegExp
.Pattern = "<[^>]+>"
.IgnoreCase = True
.Global = True
stripTags = RegularExpressionObject.Replace(HTMLstring, "")
Set RegularExpressionObject = nothing
But I don't know how to get that code to interact with my code. I'm familiar with Regular Expressions so I understand how this code does what it does. Unfortunately I don't understand anything else about it. I've tried replacing "HTMLstring" with my code but that didn't do anything.
If this code isn't enough, there's plenty of more code in my source that I can supply you with. Just tell me what I should be looking for. Any help would be greatly appreciated, thank you!
If Not rsItems.Eof Then
sDescription = rsItems("WEBDESC")
If Not rsParent.Eof Then%>
Dim objRegExp, strOutput
Set objRegExp = New Regexp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<(.|\n)+?>"
strOutput = objRegExp.Replace(strHTML, "")
strOutput = Replace(strOutput, "<", "<")
strOutput = Replace(strOutput, ">", ">")
stripHTML = strOutput 'Return the value of strOutput
Set objRegExp = Nothing