Categorias

Remover Tags HTML de uma String com Expressão Regular

Com esta função é possível remover todas as Tags HTML de uma string utilizando Expressão Regular.

Essa função pode ser bastante útil quando é preciso tratar informações submetida por algum usuário sem a “sujeira” das tags.

]*>"
    
    'Substituindo as tags encontradas pela expressão
    strTexto            = strHTML
    strTexto            = objER.Replace(strTexto, "")
    
    Set objER            = Nothing

    'Retornando a função
    RemoveHTMLTags = strTexto
End Function

'-----------------------------------------------------
'Exemplo de chamada da função
'-----------------------------------------------------
Dim HTML
HTML = "teste da função de retira as TAGS HTML
" 'Texto com TAG Response.Write HTML 'Texto sem TAG Response.Write RemoveHTMLTags(HTML) %>