我想知道如何从字符串中删除数字。我尝试使用 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;
关于string - 从字符串中删除数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10838468/