Einzelnen Beitrag anzeigen

Dax
(Gast)

n/a Beiträge
 
#33

Re: StringReplace und doppelte Zeichen

  Alt 24. Dez 2007, 21:37
*lach* Wieso funktioniert es nur bei himi? Wenn ich nur Delphi hätte, das ganze auch zu testen

Delphi-Quellcode:
function ReduceMultiples(const s: string; c: char): string;
var
  pe, pr, pc: PChar;
  i: integer;
begin
  if s = 'then exit;
  SetLength(result, Length(s));
  pc := @s[1];
  i := 0;
  while pc^ <> c do begin
    Inc(pc);
    Inc(i);
  end;
  if i > 0 then begin
    Move(s[1], result[1], i);
    pe := PChar(Integer(@s[i+1]) + Length(s) - i);
    pr := @result[i+1];
  end else begin
    pe := PChar(Integer(@s[1]) + Length(s));
    pr := @result[1];
  end;
  while pc <> pe do begin
    while (pr^ = pc^) and (pc^ = c) do
      Inc(pc);
    pr^ := pc^;
    Inc(pr);
    Inc(pc);
  end;
  SetLength(result, Integer(pr) - Integer(@result[1]));
end;
Wenn das jetzt nicht läuft, geb ichs aber auf.
  Mit Zitat antworten Zitat