Hi,
Ich habe eine Zeichenkette namens str, die Text und HTML-Code enthält. Nun möchte ich daraus alle HTML-Tags entfernen, also alles, was so aussieht: <irgendwas> . Wie geht das?
Der folgende Code funktioniert ganz gut, wo genau ich den damals her hatte weiss ich leider nicht mehr. Glaube von Stardeveloper.com.
'----------------snip---------------
'The following code strips the HTML tags from strHTML using split and join
dim arysplit, i, j, strOutput
arysplit = split(str, "<")
'Assuming paragraph-text is nonempty, we want to start iterating
'from the 2nd array postition
if len(arysplit(0)) > 0 then j = 1 else j = 0 'Loop through each instance of the array
for i=j to ubound(arysplit)
'Do we find a matching > sign?
if instr(arysplit(i), ">") then
'If so, snip out all the text between the start of the string
'and the > sign
arysplit(i) = mid(arysplit(i), instr(arysplit(i), ">") + 1)
else
'Ah, the < was was nonmatching
arysplit(i) = "<" & arysplit(i)
end if
next 'Rejoin the array into a single string
strOutput = join(arysplit, "")
'Snip out the first <
strOutput = mid(strOutput, 2-j)
'Convert < and > to < and >
strOutput = replace(strOutput,">",">")
strOutput = replace(strOutput,"<","<")
'----------------snip---------------
Gruss, Mel