View Single Post
09-20-2010, 03:27 PM
#1
jimmykup is offline jimmykup
Status: I'm new around here
Join date: Apr 2010
Location:
Expertise:
Software:
 
Posts: 11
iTrader: 0 / 0%
 

jimmykup is on a distinguished road

  Old  Stripping HTML from an ASP code and then Trimming It

Hello,

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 Goal:
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 Problem:
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.

Code:
<%=sDescription%>
I searched for a code that would help me with removing the HTML tags and I found this piece right here.

Code:
Function stripTags(HTMLstring)
    Set RegularExpressionObject = New RegExp
    With RegularExpressionObject
        .Pattern = "<[^>]+>"
        .IgnoreCase = True
        .Global = True
    End With
    stripTags = RegularExpressionObject.Replace(HTMLstring, "")
    Set RegularExpressionObject = nothing
End Function
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!

Reply With Quote