본문 바로가기
Application/Delphi Lecture

비베의 split 함수 구현

by 현이빈이 2008. 7. 24.
반응형
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;
반응형