procedure TForm1.Button1Click(Sender: TObject); var sstr,dstr:string; i:integer; begin sstr := 'abc123456'; dstr := ''; for i:=1 to Length(sstr) do begin if sstr[i] In ['0'..'9'] then dstr := dstr+ sstr[i]; end; showmessage(dstr); end;
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;
var
sstr,dstr:string;
i:integer;
begin
sstr := 'abc123456';
dstr := '';
for i:=1 to Length(sstr) do
begin
if sstr[i] In ['0'..'9'] then
dstr := dstr+ sstr[i];
end;
showmessage(dstr);
end;
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;