Autor Beitrag
Biarchiv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Di 10.03.09 19:34 
Hallo,

ich würde gerne aus einem String der jedes Zeichen im Ascii enthalten kann nur
Buchstaben und Zahlen nach der Reihenfolge rauslesen und in einem anderen String kopieren.
a..z, A..Z, 0..9
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 10.03.09 19:40 
Schnell mal getippt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function GetMyString(Value: String): String;
var
  i, Cur: Integer;
begin
  SetLength(Result, Length(Value));
  Cur := 1;
  for i := 1 to Length(Value) do
    if Value[i] in ['a'..'z''A'..'Z''0'..'9'then
    begin
      Result[Cur] := Value[i];
      Inc(Cur);
    end;
  SetLength(Result, Cur - 1);
end;
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Di 10.03.09 19:42 
Hallo,

  • Gehe alle Zeichen der Reihe nach durch
  • Prüfe, ob das aktuelle Zeichen im genannten Set (a..z, A..Z, 0..9) vorkommt
  • Wenn ja: Zeichen in Rückgabewert übertragen
  • Wenn nein: nichts tun

(Eigentlich war das jetzt so gedacht, dass der Threadstarter den Code dazu schreibt, aber da war wohl jemand schneller :()

Grüße,
Yogu
Biarchiv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 688



BeitragVerfasst: Di 10.03.09 19:59 
THX, geht super.