C#,Delphi,Oracle,MSSQL 개발자블로그

델파이 Split 함수 본문

Programming/Delphi

델파이 Split 함수

19760323 2019. 6. 12. 19:45

C#의 Split 가능과 같은 기능을 하는 함수이다.

function TForm1.Split(from, delimiter: string): TStringList;
var
   P, dl, fl: integer;
begin
   Result := TStringList.Create;
   dl := Length(delimiter);
   fl := Length(from);
   repeat
      P := Pos(delimiter, from);
      if P = 0 then
      P := fl + dl;
      Result.Add(copy(from, 1, P - 1));
      from := copy(from, P + dl, fl);
      fl := Length(from);
   until fl = 0;
end;

Comments