Fórum Substituir string !!!!! #293052
25/08/2005
0
tem que alterar o que esta dentro dos ´ ´.Desse modo:
src=´alterar tudo ki estiver aki dentro e coloca outro valor´
essa eh a linha do cod. html que tenho que alterar so que pode ter varias linhas iguais a essa.
<v:imagedata src="./Pasta1_arquivos/image001.jpg" o:title="kerry ou query"/>
Espero ter explicado bem !!!!!!
Valew
Guilherme
Curtir tópico
+ 0Posts
26/08/2005
Celamar
Gostei + 0
26/08/2005
Rjun
Gostei + 0
26/08/2005
Guilherme
Gostei + 0
26/08/2005
Cabelo
Gostei + 0
26/08/2005
Guilherme
Gostei + 0
26/08/2005
Rjun
Gostei + 0
26/08/2005
Adriano Santos
Ae, montei um algoritimo aqui usando um TEdit, consegui fazer a substituição do texto entre aspas somente do [b:dceb4a6844]src[/b:dceb4a6844] como vc necessita, agora é só dar uma adaptada a sua necessidade.
procedure TForm1.Button1Click(Sender: TObject); var I: Integer; PosIni: Integer; PosFim: Integer; ContaCaract: Integer; MeuTexto: string; MinhaFrase: string; begin MeuTexto := Edit1.Text; PosIni := Pos(´src="´, MeuTexto) + 5; ContaCaract := 0; for I := PosIni to Length(MeuTexto) do begin if MeuTexto[I] = ´"´ then // fim da src begin MinhaFrase := Copy(MeuTexto, PosIni, ContaCaract); Edit1.Text := StringReplace(MeuTexto, MinhaFrase, ´Olá mano´, []); Break; end; Inc(ContaCaract); end; end;
Gostei + 0
26/08/2005
Adriano Santos
Aqui eu uso dois Memos, eu pego a linha do primeiro, faço um StringReplace e jogo do segundo Memo.
Cara, agora foi melzinho na chupeta hein...rs....
Adiciona os memos ai e cola seu HTML dentro do primeiro e testa, funciona direitinho cara.
procedure TForm1.Button1Click(Sender: TObject); var I, J: Integer; PosIni: Integer; PosFim: Integer; ContaCaract: Integer; MeuTexto: string; MinhaFrase: string; begin for J := 0 to Memo1.Lines.Count do begin MeuTexto := Memo1.Lines[I];//Edit1.Text; PosIni := Pos(´src="´, MeuTexto) + 5; ContaCaract := 0; for I := PosIni to Length(MeuTexto) do begin if MeuTexto[I] = ´"´ then // fim da src begin MinhaFrase := Copy(MeuTexto, PosIni, ContaCaract); Memo2.Lines.Add(StringReplace(MeuTexto, MinhaFrase, ´Olá mano´, [])); Break; end; Inc(ContaCaract); end; end; end;
Gostei + 0
26/08/2005
Guilherme
var a: String; b: integer; begin try a:=Memo1.Text; while b <> 0 do begin b:=pos(´src="´,Memo1.Text)+5; if Copy(a,b,1) <> ´"´ then begin Delete(a,b,1); end else abort; end; finally Memo1.Text:=a; end; end;
so que esta acontecendo o mesmo que o cod do nosso amigo Adriano Santos ele so apaga ate o primeiro src=´ aquem sabe como que faço para que ele continue apagando ate que nao tenha mais src=´ ????
o cod html eh :
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Nova pagina 1</title> </head> <body> <p><img border="0" src="../../../Guilherme/Imagens/my¬20photos/BXK15424_ilha_tropical8.jpg" width="442" height="333"></p> <p><img border="0" src="../../../Guilherme/Imagens/my¬20photos/BXK15424_ilha_tropical9.jpg" width="442" height="333"></p> <p><img border="0" src="../../../Guilherme/Imagens/my¬20photos/BXK15424_ilha_tropical10.jpg" width="442" height="333"></p> </body> </html>
Gostei + 0
26/08/2005
Adriano Santos
var a: String; b: integer; begin try a:=Memo1.Text; while b <> 0 do begin b:=pos(´src="´,Memo1.Text)+5; if Copy(a,b,1) <> ´"´ then begin Delete(a,b,1); end else abort; end; finally Memo1.Text:=a; end; end;
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title>Nova pagina 1</title> </head> <body> <p><img border="0" src="../../../Guilherme/Imagens/my¬20photos/BXK15424_ilha_tropical8.jpg" width="442" height="333"></p> <p><img border="0" src="../../../Guilherme/Imagens/my¬20photos/BXK15424_ilha_tropical9.jpg" width="442" height="333"></p> <p><img border="0" src="../../../Guilherme/Imagens/my¬20photos/BXK15424_ilha_tropical10.jpg" width="442" height="333"></p> </body> </html>
Pow, agora não entendi [b:2a65dc7179]´gborges_13´[/b:2a65dc7179], você não precisa substituir o que tah em src por outro valor? Porque quer apagar?
[code]
Gostei + 0
26/08/2005
Guilherme
foi mal me espreçei errado !!!!! :oops: :oops:
Gostei + 0
26/08/2005
Adriano Santos
procedure TForm1.Button1Click(Sender: TObject); var I, J: Integer; PosIni: Integer; PosFim: Integer; ContaCaract: Integer; MeuTexto: string; MinhaFrase: string; begin for J := 0 to Memo1.Lines.Count do begin MeuTexto := Memo1.Lines[J]; //não pra colocar "I" no Lines e sim "J" era Memo1.Lines[I]; if Pos(´src="´, MeuTexto) > 0 then //Linha adicionada begin PosIni := Pos(´src="´, MeuTexto) + 5; ContaCaract := 0; for I := PosIni to Length(MeuTexto) do begin if MeuTexto[I] = ´"´ then // fim da src begin MinhaFrase := Copy(MeuTexto, PosIni, ContaCaract); Memo2.Lines.Add(StringReplace(MeuTexto, MinhaFrase, ´Olá mano´, [])); Break; end; Inc(ContaCaract); end; end else //else adicionado begin Memo2.Lines.Add(Memo1.Lines[J]); Continue; end; end; end;
Gostei + 0
26/08/2005
Guilherme
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)