自己写段代码就搞定了 用 in ['a'..'z','Z'..'Z', '0'..'9']判断处理即可
function Getstring(aStr: string): string; var i: integer; tempstr: string; begin result:=''; for i:=1 to length(aStr) do begin tempstr:=copy(aStr, i, 1); if (tempstr in ['0'..'9', 'a'..'z', 'A'..'Z']) then result:=result+tempstr; end; end;
但是 length(astr) 返回值是0呀。 无法确定长度
调用此函数前试下用此办法去掉控制元:var s: string; begin s:=trim('LB020'#$F5); s:=copy(s,1,200); s:=Getstring(s); end;
//去掉后面的 procedure GetString(Var AStr:String); var i,L:Integer; begin L:=Length(AStr); for i:=L Downto 1 do if Ord (AStr[i])>128 then Break else Delete(AStr,i,1); end;
for i:=1 to length(aStr) do if Not (tempstr in ['0'..'9', 'a'..'z', 'A'..'Z']) then Delete(aStr,i,1);
用 in ['a'..'z','Z'..'Z', '0'..'9']判断处理即可
var
i: integer;
tempstr: string;
begin
result:='';
for i:=1 to length(aStr) do begin
tempstr:=copy(aStr, i, 1);
if (tempstr in ['0'..'9', 'a'..'z', 'A'..'Z']) then
result:=result+tempstr;
end;
end;
无法确定长度
s: string;
begin
s:=trim('LB020'#$F5);
s:=copy(s,1,200);
s:=Getstring(s);
end;
procedure GetString(Var AStr:String);
var
i,L:Integer;
begin
L:=Length(AStr);
for i:=L Downto 1 do
if Ord (AStr[i])>128 then
Break
else
Delete(AStr,i,1);
end;
if Not (tempstr in ['0'..'9', 'a'..'z', 'A'..'Z']) then
Delete(aStr,i,1);