应用场景
把一个字符串中的某一个字符全部替换成另一个字符
函数代码
function ChangeChar(const AString: string; ASearch, AReplace: Char): string;
var
I: integer; // loops thru all chars of string
begin
Result := AString;
if Result = '' then
Exit;
for I := 1 to Length(Result) do
if Result[I] = ASearch then
Result[I] := AReplace;
end;
测试
Caption:= ChangeChar('C++', '+','-')//返回C--
···