一组字符串解析。
  1   2  3  4  5  6  7  8  9  10  11..1000
  s1  s1 s2 s3 s1 s5 s1 s4 s7 s2  s1  s10
  结果:
  s1
  s2
  s3
  s4
  s7
  s10
大家有方便的算法么?

解决方案 »

  1.   

    什么玩意?
    就是分割字符吗,用TStringList,按空格(或其它制定字符)分隔
      

  2.   

    是不是要把第二行中的重复项去掉?
    用tstringlist,设置sorted=true,Duplicates=dupIgnore,添加到列表中就行了
      

  3.   

    var
    sl:tstringlist;
    begin
      sl:=tstringlist.Create;
      sl.Delimiter:=' ';
      sl.Text:='s1  s1 s2 s3 s1 s5 s1 s4 s7 s2  s1  s10';
      sl.Sorted:=true;
      sl.Duplicates:=dupIgnore;
      sl.Free;
    end;
      

  4.   

    procedure TF_Main.btnTestClick(Sender: TObject);
    var
      sl:tstringlist;
    begin
      sl:=tstringlist.Create;
      try
        sl.Sorted:=true;
        sl.Duplicates:=dupIgnore;
        sl.Delimiter:=' ';
        sl.DelimitedText:='s1  s1 s2 s3 s1 s5 s1 s4 s7 s2  s1  s10';
        ShowMessage( sl.Text );
      finally
        sl.Free;
      end;
    end;
      

  5.   

      for tmpLoop := 0 to RowCount - 1 do
      begin
        FiledStr1[tmpLoop] := Trim(ShipList.Cells[1, tmpLoop + 1]); { 客户名称 }
        FiledStr2[tmpLoop] := Trim(ShipList.Cells[1, tmpLoop + 1]);
      end;  //查询出每一个发货单客户名称
      for tmpLoop := 0 to RowCount - 1 do
      begin
        sTmp := FiledStr1[tmpLoop];
        iTmp := 0;
        while iTmp <= tmpLoop do
        begin
          if FiledStr2[tmpLoop + 1] <> sTmp then
          begin
            FiledStr[TableCount] := sTmp;
            TableCount := TableCount + 1;                           {表累加1}
            Break;
          end;
          iTmp := iTmp + 1;
        end;
      end;
    几天没上了,想了以奔方法!楼上方法不错!