怎样从一个字符串中取得数字?如"abcd3#",要把3取出来,怎样取?

解决方案 »

  1.   

    判断每个字符的ascII,如果在那个范围里就取------------------------
    http://scsoft.agrie.com
      

  2.   

    刚写了一函数,再发给你
    procedure TForm1.Button1Click(Sender: TObject);
    var
      i:integer ;
      str,str2:string;
    begin
      str:='asdf23423asd';
      for i:=1 to length(str)  do
      begin
        if ord(str[i]) in [48..57] then
          str2:=str2+str[i];
      end;
    end;
    ------------------------
    http://scsoft.agrie.com
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    conest
    tt=['0','1',....'9']
    var
      i:integer ;
      str,str2:string;
    begin
      str:='asdf23423asd';
      for i:=1 to length(str)  do
      begin
        if not(str[i] in tt) then
          str2:=str2+str[i];//这里没有数字了
      end;
    end;