我想知道如何从字符串中删除数字。我尝试使用 StringReplace 但不知道如何告诉函数我要替换数字。
这是我尝试过的:
StringReplace(mString, [0..9], '', [rfReplaceAll, rfIgnoreCase]);
简单但有效。可以优化,但应该可以满足您的需要:
function RemoveNumbers(const aString: string): string;
var
C: Char;
begin
Result := '';
for C in aString do begin
if not CharInSet(C, ['0'..'9']) then
begin
Result := Result + C;
end;
end;
end;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)