<br>function String_Replace(<br> OldSubString: string;<br> NewSubString: string;<br> SourceString: string): string;<br>var<br> P: Integer;<br> S: string;<br> R: string;<br> LOld: Integer;<br> LNew: Integer;<br>begin<br> S := SourceString;<br> R := '';<br> LOld := Length(OldSubString);<br> LNew := Length(NewSubString);<br> Result := S;<br> if OldSubString = '' then Exit;<br> if SourceString = '' then Exit;<br> P := Pos(OldSubString, S);<br> if P = 0 then<br> begin<br> R := S;<br> end<br> else<br> begin<br> while P <> 0 do<br> begin<br> Delete(S, P, LOld);<br> R := R + Copy(S, 1, P - 1) + NewSubString;<br> S := Copy(S, P, Length(S) - (P - 1));<br> P := Pos(OldSubString, S);<br> if P = 0 then R := R + S;<br> end;<br> end;<br> Result := R;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> f: textfile;<br> filename: string;<br> tempS: string;<br> strS: TStrings;<br> i: integer;<br>begin<br> filename := 'f:/temp/try.txt';<br> AssignFile(f, filename);<br> strS := TStringList.Create;<br> try<br> reset(f);<br> while not eof(f) do<br> begin<br> tempS := '';<br> Readln(f, tempS);<br> strS.Add(String_Replace('you', 'i', tempS));<br> end;<br> CloseFile(f);<br> Rewrite(f);<br> for i := 0 to strS.Count - 1 do<br> Writeln(f, strS);<br> finally<br> CloseFile(f);<br> end;<br>end;<br>