如:输入一个字符串,内有数字,和非数字字符串,
   55jf25_552a44
将其中连续的数字作为一个整数,统计其中共有多少个整数,并输出这些整数
怎么样写这个函数,现谢谢了

解决方案 »

  1.   

    你可改一下,使其可接受传入参数:
    procedure GetIntStr;
    const
      s = '55jf25_552a44';
    var
      ib: Boolean;
      i: Integer;
      ts: string;
    begin
      ts := '';
      for i := 1 to Length(s) do
      begin
        if not (s[i] in ['0'..'9']) then
          ib := false
        else
          ib := true;
        if ib = false then
        begin
          if ts <> '' then
            Form1.Memo1.Lines.Append(ts);
          ts := '';
          Continue;
        end;
        ts := ts + s[i];
      end;
      if ts <> '' then
        Form1.Memo1.Lines.Append(ts);
    end;