Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

diego_sl

Removendo tags HTML com função

Recommended Posts

eae galera,olha só,fiz na corrida aqui uma funçãozinha q remove as tag html de uma variavel,só q sei q essa ai ta mto nobie,c a string for mto grande vai fica demorado pakas,c alguem poder dar uma otimizada nela ai fico mto grato,flw texto = "<div> OLÁ </div>" while not inStr(1,texto,"<") = 0 substituir = "" inicio = inStr(1,texto,"<") fim = inStr(1,texto,">") if CInt(inicio) > 0 then substituir = Mid(texto,inicio,fim) texto = replace(texto,substituir,"") end if wend

Compartilhar este post


Link para o post
Compartilhar em outros sites

ve se essa function serve:

Function Tira_html(texto)

pos1 = inStr(texto,"<")

pos2 = inStr(texto,">")

cont = 0

  For i = pos1 To pos2

  cont = cont + 1

  Next

  trata = Mid(texto,pos1+cont,Len(texto))

  Tira_html = trata

End Function

 

textos = "<strong> OLÁ BABY </strong>"

Response.Write Tira_html(textos)

Compartilhar este post


Link para o post
Compartilhar em outros sites

eae galera,olha só,fiz na corrida aqui uma funçãozinha q remove as tag html de uma variavel,só q sei q essa ai ta mto nobie,c a string for mto grande vai fica demorado pakas,c alguem poder dar uma otimizada nela ai fico mto grato,flw texto = "<div> OLÁ </div>" while not inStr(1,texto,"<") = 0 substituir = "" inicio = inStr(1,texto,"<") fim = inStr(1,texto,">") if CInt(inicio) > 0 then substituir = Mid(texto,inicio,fim) texto = replace(texto,substituir,"") end if wend

tipo, essa função ,com certeza dará uns erros no mid.......pq ja leu a sitaxe da funcao mid ???

Compartilhar este post


Link para o post
Compartilhar em outros sites

aki ja testei ela a vera e naum deu nda...só axo q podia ser + rápida,mas erro naum deu nenhum

mid(texto,inicio,qtde)texto é o texto mesmoinicio é a partir de onde tu vai começar.... qtde é a qtde de chars q tu vai pegar depois do inicio

Compartilhar este post


Link para o post
Compartilhar em outros sites

aki ja testei ela a vera e naum deu nda...só axo q podia ser + rápida,mas erro naum deu nenhum

mid(texto,inicio,qtde)texto é o texto mesmoinicio é a partir de onde tu vai começar.... qtde é a qtde de chars q tu vai pegar depois do inicio
depois q tu falo ali eu m ligue,realmente ta cum emrda,hehe,o unico caso q iria funcionar era mesokm com a tag q eu tava testando aki,hehehe,mas ja corrigifico assim ó:
   while not inStr(texto,"<") = 0      substituir = ""      inicio = inStr(texto,"<")      fim = inStr(texto,">")      caracteres = CInt(fim) - (inicio) + 1      if CInt(inicio) > 0 then        substituir = Mid(texto,inicio,caracteres)         texto = replace(texto,substituir,"")      end if    wend

Compartilhar este post


Link para o post
Compartilhar em outros sites

n serve htmlencode?

é q tipo cara,se eu passar um htmlencode na string,na hora de eu exibir em tela,vai ficar assim:<b>lala</b><br>lala<br><p>lala</b>e isso naum m serve eu preciso do texto puto ou sejata armazenado no banco akele texto ali em cima,como htmlk,e quando for exibir em tela preciso que fique asim:lalalalalalasem as tags saka? ;-)

Compartilhar este post


Link para o post
Compartilhar em outros sites

Funcionar funciona não sei se atende suas necessidades.

"pattern"

 

 

<%Function RemoverHTML( strText )Dim RegExSet RegEx = New RegExpRegEx.Pattern = "<[^>]*>"RegEx.Global = TrueRemoverHTML = RegEx.Replace(strText,"")End Functioneste= vbcrlf &"wagner valerio do sacramento"sTexto = "<table>"sTexto = sTexto & "<td align= left whidt=62><font class=normal>1536 " & este &" </font></td>" & vbcrlfsTexto = sTexto & "<td align= left whidt=75><font class=normal> 18/06/2003 </font></td>" & vbcrlfsTexto = sTexto & "<td align= left whidt=80><b>concluido</b></td>" & vbcrlfsTexto = sTexto & "<td align= left whidt=62><font class=normal>1548</font></td>" & vbcrlfsTexto = sTexto & "<td align= left whidt=75><font class=normal> 17/09/2002 </font></td>" & vbcrlfsTexto = sTexto & "<td align= left whidt=80><b>extinto </b></td>" & vbcrlfsTexto = sTexto & "</table>" & vbcrlftbString = Split(sTexto,vbcrlf)for i = LBound(tbString) to UBound(tbString)sLinha = RemoverHTML(tbString(i))if Len(sLinha) > 0 then  response.write sLinha & "<br>"end ifnext%><//--ABAIXO ESTA UMA FUNCAO DE TESTE DE REG.EX--><%response.end Function RegExpTest(patrn, strng)   Dim regEx, Match, Matches   ' Create variable.   Set regEx = New RegExp   ' Create a regular expression.   regEx.Pattern = patrn   ' Set pattern.   regEx.IgnoreCase = True   ' Set case insensitivity.   regEx.Global = True   ' Set global applicability.   Set Matches = regEx.Execute(strng)   ' Execute search.   For Each Match in Matches   ' Iterate Matches collection.      RetStr = RetStr & "Match found at position "      RetStr = RetStr & Match.FirstIndex & ". Match Value is '"      RetStr = RetStr & Match.Value & "'." & vbCRLF   Next   RegExpTest = RetStrEnd Function'RegExpTest("is.","IS1 is2 IS3 is4")%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.