如果我的字符串是 : sdfsfs[12345678]
                    dfhjdfjdjdf[33345678]我要把后面的[12345678] 和[33345678] 去掉,得到的剩下的部分赋值给另外的字符,怎么办啊?

解决方案 »

  1.   

    copy('sdfsfs[12345678]',1,pos(']','sdfsfs[12345678]')-1)
    上面就得到adfsfs
      

  2.   

    对不起,写错了,是这样
    copy('sdfsfs[12345678]',1,pos('[','sdfsfs[12345678]')-1)
      

  3.   

    function PartitionString(StrV,PrtSymbol: string): TStringList;
    var
      iTemp: integer;
    begin
      result := TStringList.Create;
      iTemp := pos(PrtSymbol,StrV);
      while iTemp>0 do begin
        if iTemp>1 then result.Append(copy(StrV,1,iTemp-1));
        delete(StrV,1,iTemp+length(PrtSymbol)-1);
        iTemp := pos(PrtSymbol,StrV);
      end;
      if Strv<>'' then result.Append(StrV);
    end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
      BBStr:TStrings;
    begin
      BBStr:=PartitionString('sdfsfs[12345678]','[');
      ShowMessage(BBStr[0]);
    end;这样就得到你要的sdfsfs了.
      

  4.   

    bee2518(迷茫ing)写得不错,我也是这个思路,可惜来晚了
    copy('sdfsfs[12345678]',1,pos('[','sdfsfs[12345678]')-1