请问各位大虾如果
我相从字符串"f[1]+f[8]+f[10]+f[22]" 中截取出其中的 1,8,10,22 放进一个数组中
我改怎么做呢?

解决方案 »

  1.   

    copy(f[1]+f[8]+f[10]+f[22]" ,i*X,y)
      

  2.   

    copy(string,x,y)
    你自己看一下帮助吧。
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    const
      Res = 'f[1]+f[8]+f[10]+f[22]';
    var
      str: string;
      s: TStringList;
      a: array of integer;
      i: integer;
    begin
      str := StringReplace(Res, '+', ',', [rfReplaceAll]);
      s := TStringList.Create;
      s.CommaText := str;
      SetLength(a, s.Count);
      for i := 0 to s.Count - 1 do
      begin
        a[i] := StrToInt(Copy(s.Strings[i], 3, Length(s.Strings[i]) - 3));
        ShowMessage(IntToStr(a[i]));
      end;
    end;
      

  4.   

    procedure ParseString(const Source: string; S: TStrings);
    var I, J: Integer;
    begin
      S.Clear;
      I := 1;
      J := 1;
      repeat
        I := PosEx('[', Source, I + 1);
        J := PosEx(']', Source, J + 1);
        if I < J then
          S.Add(Copy(Source, I + 1, J - I - 1));
      until I = 0;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      ParseString('f[1]+f[8]+f[10]+f[22]', ListBox1.Items);
    end;
      

  5.   

    哈哈 太谢谢各位了 
    特别鸣谢 budded(System is bussy!) , luke5678(奇异) 两位大虾!!谢谢