您的位置:首页 > 编程语言 > Delphi

(Delphi中处理字符串)截取中文字符和英文字符,去除所有数字

2014-10-18 11:15 706 查看
处理对象:"200个",截取结果"个"

处理对象:"200kg",截取结果"kg"

function TFmxsdd_dzbh.getTheUnit(str:string):string;
var
n,i :integer;
ch: byte;
s:string;
begin
s:='';
n:=length(str);
i:=1;
while i<=n   do
begin
if not (str[i] in ['0'..'9']) then
begin
ch := Byte(str[i]);
if Windows.IsDBCSLeadByte(ch) then
begin
s:= s+ Copy(str, i, 2);
i:=i+1;
end
else
s:= s + str[i];
end;
i:=i+1;
end;
Result:=s;
end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐