从字符串中取数字

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
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 in charset) then
result:= result + uppercase(str);
end;
end;
可以取得十六进制的数字!可以包含小数点,但你必须保证只有一个小数点!
 

Similar threads

S
回复
0
查看
631
SUNSTONE的Delphi笔记
S
S
回复
0
查看
607
SUNSTONE的Delphi笔记
S
I
回复
0
查看
598
import
I
S
回复
0
查看
955
SUNSTONE的Delphi笔记
S
S
回复
0
查看
777
SUNSTONE的Delphi笔记
S
顶部