Anybody know how to go about removing all html from user entered text?
Printable View
Anybody know how to go about removing all html from user entered text?
How is the user to enter this ?
You could use vb's replace function if it's small :
Or are you looking at a whole web page type thing ???Code:REPLACE "<HTML>", text1.text, ""
I could but the I would have to write a rplace for every html tag and then parse the text looking for hrefs,img,form... since the tags vary. I was hoping there was a better way to do it
Just convert the < and > to > and <
J, awkward but I think needed. If you could give me an example of what this is for / the context you need this for would help. ;)
Josh, that would still keep :
HTML from :
<HTML>
so he would get a load of extra words in his text.
What you could do is use an array for all the tags, something like :
Code:Dim ArrTag(5) as variant
'Note : Arrays always start at 0, so me declaring a scope
of 5 spaces here really gives 6 - 0,1,2,3,4 and 5
ArrTag = Array(<HTML>, <HEAD>, <BODY>, <SCRIPT>, <TABLE>, <TR>, <TD>)
So you only type them once, put each tag into an array
For i = 0 to ubound(ArrTag)
'Go through all the array until the bottom entry is reached
Replace ArrTag(i), Text1.text, ""
' change the tag with a blank space
Next i
VBScript supports regular expressions now, right? I have some Perl code somewhere I wrote a couple years ago that will strip HTML tags from user text. What it basically would do is to find < and the next >, and strip them and everything in between.