如何实现替换文本文件中某些字符串?(0分)

  • 主题发起人 主题发起人 folmorse
  • 开始时间 开始时间
F

folmorse

Unregistered / Unconfirmed
GUEST, unregistred user!
我想把一个已有的文本文件中某些字符串替换成我制定的字符串,请问如何实现? <br><br>--<br>
 
以前的帖子里有很多方法啊?你干嘛不自己查查呢??<br>procedure TForm1.FindClick(Sender: TObject);<br>&nbsp; var<br>&nbsp; &nbsp; &nbsp;i : Integer;<br>&nbsp; &nbsp; &nbsp;str1,str2,pathstr : String;<br>&nbsp; &nbsp; &nbsp;List : TStringList;<br>&nbsp; begin<br>&nbsp; &nbsp; str1 := ???; &nbsp;//要被替换的字符串<br>&nbsp; &nbsp; str2 := ???; &nbsp;//要替换成的字符串<br>&nbsp; &nbsp; pathstr := ???; //文本文件路径及文件名.<br>&nbsp; &nbsp; List := TStringList.Create;<br>&nbsp; &nbsp; List.LoadFromFile(pathstr);<br>&nbsp; &nbsp; for Counter := 0 to List.Count - 1 do<br>&nbsp; &nbsp; &nbsp; list := stringreplace(List,str1,str2,[rfReplaceAll]);<br>&nbsp; &nbsp; List.SaveToFile( Pathstr );<br>&nbsp; &nbsp; List.free;<br>&nbsp; end;<br>
 
谢谢wjiachun大虾,只可惜我已经没钱了,下次补上!xi,xi...
 
后退
顶部