取以分隔符间隔字符串的指定列

例串:A1,,HIV,Unknown,Undetermined,,,,,,,,,

{-------------------------------------------------------------------------------
  过程名:    TForm1.split
  作者:      Gsl
  日期:      2010.04.24
  参数:      str: string; pos: Integer 指定串及列位置
  返回值:    string
-------------------------------------------------------------------------------}
function TForm1.split(str: string; pos: Integer): string;
  var
    i_pos1, i_pos2, i:Integer;
  begin
    i_pos1:=0;
    i_pos2:=0;
    for i:=1 to pos do
    begin
      i_pos1:=i_pos2;
      i_pos2:=PosEx(',', str, i_pos1+1);
    end;
    Result:=Copy(str, i_pos1+1, i_pos2-i_pos1-1);
end;

原文地址:https://www.cnblogs.com/wjhx/p/1719106.html