Fjernelse af html fra filer
Jeg vil gerne have fjernet alt html fra nogle html-sider. Jeg har lavet følgende funktion men den går i stå og CPU forbruget kommer helt op på 100%.Hvorfor virker det ikke?
Function no_tags(strtext2)
text_string1 = strtext2
if text_string1 <> "" then
WScript.Echo "Length: " & len(text_string1)
if len(text_string1) > 100000 then
text_string1 = left(text_string1,100000)
end if
text_string1 = mid(replace(" "&text_string1,"<script","<script",1,-1,1),2)
text_string1 = mid(replace(" "&text_string1,"</script>","</script>",1,-1,1),2)
While Instr((text_string1),"<script") > 0 and Instr((text_string1),"</script>") > 0
text_string1 = left(text_string1,Instr((text_string1),"<script")-1) & mid(text_string1,Instr((text_string1),"</script>")+len("</script>"))
Wend
While Instr((text_string1),"<!--") > 0 and Instr((text_string1),"-->") > 0
text_string1 = left(text_string1,Instr((text_string1),"<!--")-1) & mid(text_string1,Instr((text_string1),"-->")+len("-->"))
Wend
While Instr((text_string1),"<") > 0 and Instr((text_string1),">") > 0
text_string1 = left(text_string1,Instr((text_string1),"<")-1) & mid(text_string1,Instr((text_string1),">")+len(">"))
Wend
text_string1 = mid(replace(" "&text_string1,Chr(13),""),2)
text_string1 = mid(replace(" "&text_string1,Chr(10)," "),2)
text_string1 = mid(replace(" "&text_string1,Chr(9)," "),2)
While Instr(text_string1," ") > 0
text_string1 = replace(text_string1," "," ")
Wend
no_tags = text_string1
end if
End Function