php中的explode函数很方便,能将“a,b,c”或“a/b/c”中被格开的字符单独提取出来,不知道Delphi中有无类似的函数?

解决方案 »

  1.   

    用Copy和Pos自己写一个。function GetString(SrcStr, SprStr: String): String;
    var Index: Integer;
    begin
      Result:= '';
      while True do
      begin
        Index:= Pos(SprStr, SrcStr);
        if Index = 0 then
        begin
          Result:= Result + SrcStr;
          Break;
        end;
        Result:=Result + Copy(SrcStr, 1, Index - 1);
        SrcStr:= Copy(SrcStr, Index + Length(SprStr), Length(SrcStr));
      end;
    end;procedure TForm1.A1Click(Sender: TObject);
    begin
      Edit2.Text:= GetString(Edit1.Text, ',');
    end;