给你写个例子:
function ReplaceChar (const s: string;
ch1: char
ch2: char): string;
var i: integer;
begin
Result := s;
for i := 1 to length (Result) do
if Result = ch1 then
Result := ch2;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
S :String;
begin
S :='asdf';
S :=ReplaceChar(S,S[1],S[4]);//以f替换a
ShowMessage(S);
end;