从字符串中取数字

 function GetNumFromStr(const str: String;const hex:boolean=false): String;
var
 i:integer;
 charset:Set of char;
begin
if hex then
 charset:=['0'..'9','a'..'f','A'..'F','.']
else
 charset:=['0'..'9','.'];
for i := 1 to Length(str) do
  begin
    if (str[i] in charset) then
      result:= result + uppercase(str[i]);
  end;
end;

可以取得十六进制的数字!可以包含小数点,但你必须保证只有一个小数点!

原文地址:https://www.cnblogs.com/hnxxcxg/p/2940856.html