Einzelnen Beitrag anzeigen

Benutzerbild von Dalai
Dalai

Registriert seit: 9. Apr 2006
1.680 Beiträge
 
Delphi 5 Professional
 
#2

AW: replace string in text files

  Alt 17. Jan 2020, 18:39
Well, the easy way would be something like this: Read the file into a TStringList variable (Delphi-Referenz durchsuchenTStringList.LoadFromFile) and replace everything in Delphi-Referenz durchsuchenTStringList.Text from (and including) <header> to </header> with "<header>your_new_text</header>" with the Delphi-Referenz durchsuchenStringReplace function. However, I doubt that this will be the fastest way in terms of performance (e.g. because the .Text property makes a copy of the whole string).

[EDIT]
It just came to me that StringReplace in Delphi doesn't work with offsets. So, you probably need to determine the offset of <header> and </header> tags with Delphi-Referenz durchsuchenPos function and use Delphi-Referenz durchsuchenCopy function to get the substring between these tags and then use StringReplace on that substring.
[/EDIT]

Regards
Dalai

Geändert von Dalai (17. Jan 2020 um 20:00 Uhr)
  Mit Zitat antworten Zitat