Thema: Delphi Beliebigkeitssymbol?

Einzelnen Beitrag anzeigen

Benutzerbild von bigben37
bigben37

Registriert seit: 19. Dez 2007
Ort: Freiburg
116 Beiträge
 
Delphi 2009 Professional
 
#8

Re: Beliebigkeitssymbol?

  Alt 1. Nov 2008, 19:34
Ich hab jetzt mal schnell ne Funktion geschrieben:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := ReplaceArea(Edit1.Text, '[', ']', '0');
end;

function TForm1.ReplaceArea(CurrentS, FromS, ToS, ReplcS: string): string;
var
  FromSPos, ToSPos: Integer;
begin
  result := '';
  FromSPos := Pos(FromS, CurrentS);
  ToSPos := Pos(ToS, CurrentS);
  while (FromSPos > 0) and (ToSPos > 0) do
    begin
      Delete(CurrentS, FromSPos, ToSPos - FromSPos + Length(ToS));
      Insert(ReplcS, CurrentS, FromsPos);
      FromSPos := Pos(FromS, CurrentS);
      ToSPos := Pos(ToS, CurrentS);
    end;
  result := CurrentS;
end;
Wurde das so gehen?
Benjamin
Optimismus ist nur ein Mangel an Information
  Mit Zitat antworten Zitat