tirar ponto e traço de uma string?
[b:1221ebccd4] Como faço para tirar ponto(.) e traço (-) de uma string no caso estou convertendo uma base de dados.
ex .: 123456-96
123.123.12-6
gostaria de tirar os tarços e os pontos da string
ex .: 12345696
123123126[/b:1221ebccd4]
ex .: 123456-96
123.123.12-6
gostaria de tirar os tarços e os pontos da string
ex .: 12345696
123123126[/b:1221ebccd4]
Guigao
Curtidas 0
Respostas
Hatrix
15/05/2003
tente usar isso:
procedure TForm1.Button2Click(Sender: TObject);
var i,j : integer;
texto:string;
textofinal:string;
begin
texto := edit1.text;
textofinal := ´´;
for i:=1 to length(texto) do
begin
if not((copy(texto,i,1) = ´-´)or(copy(texto,i,1) = ´.´)) then
begin
textofinal := textofinal+copy(texto,i,1);
end;
end;
label1.caption := textofinal;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j : integer;
texto:string;
textofinal:string;
begin
texto := edit1.text;
textofinal := ´´;
for i:=1 to length(texto) do
begin
if not((copy(texto,i,1) = ´-´)or(copy(texto,i,1) = ´.´)) then
begin
textofinal := textofinal+copy(texto,i,1);
end;
end;
label1.caption := textofinal;
end;
GOSTEI 0
4_olho
15/05/2003
Crie uma string auxiliar.
Percorra a string original, caracter a caracter;
Veja se o caracter está em [0..9];
Em caso afirmativo, adicione este caracter na string auxiliar;
Em caso negativo, vá para o próximo
No final se desfaça da string original e renomeie a auxiliar
Desculpe não lhe dar o peixe ...
Percorra a string original, caracter a caracter;
Veja se o caracter está em [0..9];
Em caso afirmativo, adicione este caracter na string auxiliar;
Em caso negativo, vá para o próximo
No final se desfaça da string original e renomeie a auxiliar
Desculpe não lhe dar o peixe ...
GOSTEI 0
By Alemão
15/05/2003
procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
Edit2.Text := ´´;
for i:=1 to Length(Edit1.Text) do begin
if (copy(Edit1.Text,i,1) = ´.´) or (copy(Edit1.Text,i,1) = ´-´) then
Edit2.Text := Edit2.Text
else Edit2.Text := Edit2.Text + (copy(Edit1.Text,i,1));
end;
end;
var
i : integer;
begin
Edit2.Text := ´´;
for i:=1 to Length(Edit1.Text) do begin
if (copy(Edit1.Text,i,1) = ´.´) or (copy(Edit1.Text,i,1) = ´-´) then
Edit2.Text := Edit2.Text
else Edit2.Text := Edit2.Text + (copy(Edit1.Text,i,1));
end;
end;
GOSTEI 0
E_gama
15/05/2003
procedure TForm1.Button1Click(Sender: TObject); const NaoCopiar = ´-.,=+´; // Os caracteres que serão excluídos var I: Integer; S: string; begin Edit2.Text := ´´; S := Edit1.Text; for I := 1 to Length(S) do begin if Pos(S[I], NaoCopiar) = 0 then Edit2.Text := Edit2.Text + S[I]; end; end;
GOSTEI 0
Dcport
15/05/2003
Também quero participar do concurso... :)
-- dcport
function KeepOnlyDigits(var Texto: string): string; var i, j: Integer; begin j := 0; for i := 1 to Length(Texto) do if Texto[i] in [´0´..´9´] then begin Inc(j); Texto[j] := Texto[i]; end; SetLength(Texto, j); Result := Texto; end;
-- dcport
GOSTEI 0