Registriert seit: 24. Dez 2002
Ort: Hamburg-Harburg
3.551 Beiträge
|
Re: Ausschneiden mit Delete
26. Jul 2005, 14:49
Delphi-Quellcode:
function gettok(const s: string; const tokidx: integer; const c: char): string;
var
i, n: integer;
LastWasC: boolean;
begin
result := ''; LastWasC := false;
if (s <> '') and (tokidx > 0) then
begin
n := 0;
for i := 1 to length(s) do
begin
if ((s[i] <> c) and (LastWasC)) or ((s[i] <> c) and (n = 0)) then
begin
inc(n);
if n > tokidx then
exit;
end;
if (s[i] <> c) and (n = tokidx) then
result := result + s[i];
LastWasC := s[i] = c;
end;
end;
end;
function numtok(const s: string; const c: char): integer;
var
i: integer;
LastWasC: boolean;
begin
result := 0;
if s <> '' then
begin
LastWasC := false;
for i := 1 to length(s) do
begin
if (s[i] <> c) and ((LastWasC) or (result = 0)) then
inc(result);
LastWasC := s[i] = c;
end;
end;
end;
und dann ganz einfach:
Delphi-Quellcode:
procedure irgendwas;
const
DeinString = ' ftp=195.100.85.159:3128;gopher=195.100.85.159:3128;http=195.100.85.159:3128;https=195.100.85.159:3128';
var
I: Integer;
begin
for I := 0 to NumTok(DeinString, ' ;') do
begin
if Copy(GetTok(DeinString, I, ' ;'), 1, 5) = ' http=' then
begin
Edit1.Text := GetTok(GetTok(DeinString, I, ' ;'), 1, ' :'); // IP In Edit1
Edit2.Text := GetTok(GetTok(DeinString, I, ' ;'), 2, ' :'); // Port in Edit2
Break;
end;
end;
end;
Mario
|
|
Zitat
|