我有一个这样的字符串,内容为abcdefg*abcdefalsk*asdlkjh*alskd*alsd*
我要把*前的信息提取出来.我记的delphi中有一个相关的函数,

解决方案 »

  1.   

    var
      str:string;
      intI:Integer;
    begin
      str:='abcdefg*abcdefalsk*asdlkjh*alskd*alsd*';
      intI:=pos('*',str);
      while intI>0 do
      begin
        self.ListBox1.Items.Add(copy(str,1,IntI-1));
        str:=copy(str,intI+1,length(str)-IntI);
        intI:=Pos('*',str);
      end;
    end;
      

  2.   

    我要把他们分解以后,给不同的变量,例如
    '**asdlkjh*alskd*alsd*'
    a:=abcdefg
    b:=abcdefalsk
    .
    .
    .
    这些都由程序自动来完成.
      

  3.   

    你可以把这里用一个TStringList来保存截取后的字符串var
      str,a,b:string;
      intI:Integer;
      strList:TStringList;
    begin
      strList:=TStringList.Create;  str:='abcdefg*abcdefalsk*asdlkjh*alskd*alsd*';
      intI:=pos('*',str);
      while intI>0 do
      begin
        strList.Add(copy(str,1,IntI-1));
        str:=copy(str,intI+1,length(str)-IntI);
        intI:=Pos('*',str);
      end;
      /////
      a:=strList.Strings[0];
      b:=strList.Strings[1];
      ................
      strList.Free;
    end;
      

  4.   

    基本上这个就是Pos+Copy+System.Delete方法的组合,经常用