VB icon

Remove HTML

Submitted on: 1/6/2015 12:37:00 AM
By: Andrew Forbes (from psc cd)  
Level: Advanced
User Rating: By 2 Users
Compatibility: ASP (Active Server Pages)
Views: 722
     The trimHTML(string) function removes any html tags that are embedded in the string.
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
' Name: Remove HTML
' Description:The trimHTML(string) function removes any html tags that are embedded in the string.
' By: Andrew Forbes (from psc cd)
' Inputs:a string
' Returns:the string, with all html elements removed.
' Assumes:Useage:
x = trimHTML("a string with <b>html</b>") 
which produces: "a string with html"

function TrimHTML(strHTML)
	dim iteration
	do until instr(1,strHTML,"<")=0 and instr(1,strHTML,">")=0
		if b>0 then
			c = instr(b+1,strHTML,">")
			if c>0 then
				retVal = mid(strHTML,b,c-(b-1))
			end if
		end if
		iteration = iteration + 1
		if iteration=1000 then exit do
	TrimHTML= strHTML
End function
dim str
str="952-91</font><font size="+chr(34)+"+1"+chr(34)+" color="+chr(34)+"#0000FF"+chr(34)+">7-0489</font>"
Original text with html: <% =str %><br>
text with html removed: <% =TrimHTML(str) %>

Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.