Einzelnen Beitrag anzeigen

Benutzerbild von Jasocul
Jasocul

Registriert seit: 22. Sep 2004
Ort: Delmenhorst
1.371 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Wie kann man diesen Code optimieren

  Alt 10. Apr 2025, 11:41
Ich habe es einfach mal an die KI weitergegeben. Ergebnis:
Delphi-Quellcode:
function CleanUpText(const S: String): String;
const
  CharsToRemove: set of Char = [' ', '-', Chr(151), '_', ':', ';', ',', '.', '!', ''''];
var
  I, J: Integer;
begin
  SetLength(Result, Length(S));
  J := 1;
  for I := 1 to Length(S) do
    if not (S[I] in CharsToRemove) then
    begin
      Result[J] := S[I];
      Inc(J);
    end;
  SetLength(Result, J - 1);
end;
Peter
  Mit Zitat antworten Zitat