Caracteres Especiais
Bom Dia, Gostaria de saber se existe uma rotina que limpa de um string caracteres especias .
Grato
Luis
Grato
Luis
Guigosnet
Curtidas 0
Respostas
Marco Salles
19/07/2006
Amigo deve exixtir algo na Vcl.. mas me faha a memória
Talvez isto lhe sirva
[b:f1837c8cdb]Para chamar :[/b:f1837c8cdb]
Talvez isto lhe sirva
function CharEspeciais(Texto:String):String; var i,t:integer; begin t:=length(texto); i:=1; While i <= t do begin if texto[i] in [´1´..´9´,´a´..´z´,´A´..´Z´] Then result:=result+Texto[i]; i:=i+1; end; end;
[b:f1837c8cdb]Para chamar :[/b:f1837c8cdb]
procedure TForm1.Button1Click(Sender: TObject); begin edit1.Text:=CharEspeciais(Edit1.text); end;
GOSTEI 0
Bruno Belchior
19/07/2006
Adapte às suas necessidades:E na chamada:
function RetiraCaracteresEspeciais(Texto: string; Caracteres: array of Char): string; var Cont: Smallint; StrCaractere: string; begin for Cont := 0 to Length(Caracteres)-1 do Texto := StringReplace(Texto, Caracteres[Cont], ´´, [rfReplaceAll, rfIgnoreCase]); Result := Texto end;
procedure Chamadora; const Caracteres: array [0..11] of char = (´"´, ´!´, ´´, ´@´, ´$´, ´¬´,´¨´,´&´,´*´,´(´,´)´,´(´); var Texto: string; begin Texto := $adsf$¨$$¬´; Texto := RegiraCaracteresEspeciais(Texto , Caracteres); ShowMessage(Texto); end;
GOSTEI 0