Re: How to search for a specific string in a txt file (FindComponent?)
- From: "Bruce Roberts" <ber@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 Apr 2005 16:25:14 -0400
<pjwolters@xxxxxxxxx> wrote in message
news:1114456563.484880.239940@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Can anyone tell me how to find a specific string in a txt file.
> I need to find this string and then change it into something else. I've
> tried using the FindComponent but no success.
procedure ReplaceStringInFile (const fileName, oldStr, newStr : string);
var ms : tStringList;
begin
if FileExists (fileName)
then begin
ms := tStringList.Create;
try
ms.LoadFromFile (fileName);
ms.Text := StringReplace (ms.Text, oldStr, newStr, [rfReplaceAll,
rfIgnoreCase]);
ms.SaveToFile (fileName);
finally
ms.Free;
end;
end
else raise Exception.Create ('Cannot find file "' + fileName + '".');
end;
.
- References:
- Prev by Date: Re: How to search for a specific string in a txt file (FindComponent?)
- Next by Date: Free Delphi 2005 Professional....
- Previous by thread: Re: How to search for a specific string in a txt file (FindComponent?)
- Next by thread: How to search for a specific string in a txt file (FindComponent?)
- Index(es):
Relevant Pages
|