Buscar

Como tira caracter especial de uma string;

Código

// Como tira caracter especial de uma string;

function TiraCaracterEspecial(texto : String) : String;
begin
  if (texto <> '') then Texto := StringReplace(Texto, 'ç', 'c', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'à', 'a', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'á', 'a', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'ó', 'o', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'ã', 'a', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'ê', 'e', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'ô', 'o', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '§', ' ', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '$', ' ', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '@', ' ', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '£', ' ', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, 'ü', 'u', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '#', ' ', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '1ª', '1', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '1º', '1', [rfreplaceall]);
  if (texto <> '') then Texto := StringReplace(Texto, '  ', ' ', [rfreplaceall]);

  Result := Texto;
end;

// Como usar...

procedure TForm1.edit1Exit(Sender: TObject);
begin
 edit1.Text := TiraCaracterEspecial(edit1.Text);
end;

Publicidade

Vote na dica




Quantidade de votos: 0 votos
Aceitação: 0%


Detalhes da dica

Categoria: Forms
Adicionada dia: 02/05/07
Por: Elias R. De M. Junior
Visualizada: 7733 vezes

Planeta Delphi - Tudo sobre programação Delphi Planeta Delphi - www.planetadelphi.com.br - Todos os direitos reservados | Copyright 2001-2009