quinta-feira, 21 de fevereiro de 2008

StripTags

Função que remove todas as tags HTML

Function StripTags(ByRef Str)

Str = Str & ""
If Str = "" Then
StripTags = ""
Exit Function
End If

Dim nw, i, j, c, k, x

i = 1
x = 1
k = Len(Str)
nw = ""

Do While i > 0
i = InStr(i, Str, "<")
If i = 0 Then Exit Do

j = InStr(i, Str, ">")
If j < i Then Exit Do

c = Mid(Str, i + 1, 1)
If ereg("^[a-zA-Z/!]$", c) Then
nw = nw & Mid(Str, x, i - x)
i = j + 1
x = i
Else
i = i + 1
End If

If i >= k Then Exit Do
Loop

nw = nw & Mid(Str, x, k - x + 1)
StripTags = nw

End Function

Nenhum comentário: