delphi 提取字符中的数字

Function Setstring(cString:string):string;   {提取数字}
 VAr
   i:integer;
   str:string;
  begin
    str:='';
      For i:=1 to length(cString) do
          begin
           if Pos(cString[i],'0123456789.')<=0 then
             break
           else
            Case cString[i] of
             '.': str:=Str+'.'; 

             '0': str:=Str+'0';   '1': str:=Str+'1'; '2': str:=Str+'2';
             '3': str:=Str+'3';   '4': str:=Str+'4'; '5': str:=Str+'5';
             '6': str:=Str+'6';   '7': str:=Str+'7';
             '8': str:=Str+'8';   '9': str:=Str+'9';
            end;
    end;
    Setstring:=str;
  end;
 
如121545ADFDF.121 提取之后是 121545 函数中去掉break命令部份,结果便是:121545.121 

posted on 2016-04-24 21:00  为人民服务  阅读(3215)  评论(0编辑  收藏  举报