Stripping HTML Tags
By Abd Shomad
Note from Scott Mitchell, webmaster:
Ah, it's nice to see an article by Abd. It's been too long since
his last article! This nifty little script will strip all the HTML tags from out of a string.
Here's a way to Strip HTML Tags. I found this snippet of code is very usefull when you want to output either HTML or PLAIN TEXT with your ASPMail/CDONTS component. (To learn more about sending emails through an ASP page, be sure to read the Email FAQ Category section at ASPFAQs.com!)
Here's the code:
|
For this to work, your HTML tags must be VALID HTML tags! If you have any < or >, that do not denote the beginning of an HTML tag, you need to repalce < with < and > with > (for example, if you have in your HTML string: "The following is a true statement: 5 < 10", you would need to replace the < with <.)
| A More Updated Version |
|---|
| The above function is a bit buggy and picky, requiring a matching number of < and > signs. A cleaner and more flexible HTML stripping function can be found at: Stripping HTML Tags Using Regular Expressions. |
Happy Programming!
Attachments:
StripHTMLTag in text format


