반응형
procedure THttpControler.split(separator, Content: string; Strings: TStringList);
var
i: integer;
position: integer;
sepa_leng: integer;
item: string;
sepa_content: string;
begin
position := 0;
sepa_leng := length(separator);
sepa_content := Content;
Strings.BeginUpdate;
try
i := Pos(separator, sepa_content);
while i > 0 do
begin
item := copy(sepa_content,position, i-1);
sepa_content := copy(sepa_content, i+sepa_leng, length(Content));
Strings.Add(item);
i := Pos(separator, sepa_content);
end;
Strings.Add(sepa_content)
finally
Strings.EndUpdate;
end;
end;
var
i: integer;
position: integer;
sepa_leng: integer;
item: string;
sepa_content: string;
begin
position := 0;
sepa_leng := length(separator);
sepa_content := Content;
Strings.BeginUpdate;
try
i := Pos(separator, sepa_content);
while i > 0 do
begin
item := copy(sepa_content,position, i-1);
sepa_content := copy(sepa_content, i+sepa_leng, length(Content));
Strings.Add(item);
i := Pos(separator, sepa_content);
end;
Strings.Add(sepa_content)
finally
Strings.EndUpdate;
end;
end;
반응형