README.md

December 5, 2022 ยท View on GitHub

Remove HTML

Description

The trimHTML(string) function removes any html tags that are embedded in the string.

More Info

a string

Useage:

x = trimHTML("a string with html")

which produces: "a string with html"

the string, with all html elements removed.

Submitted On
ByAndrew Forbes
LevelAdvanced
User Rating5.0 (10 globes from 2 users)
CompatibilityASP (Active Server Pages)
CategoryStrings
WorldASP / VbScript
Archive File

Source Code

<%
function TrimHTML(strHTML)
	dim iteration
	iteration=0
	do until instr(1,strHTML,"<")=0 and instr(1,strHTML,">")=0
		b=instr(1,strHTML,"<")
		if b>0 then
			c = instr(b+1,strHTML,">")
			if c>0 then
				retVal = mid(strHTML,b,c-(b-1))
				strHTML=Replace(strHTML,retVal,"")
			end if
		end if
		iteration = iteration + 1
		if iteration=1000 then exit do
	loop
	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) %>