Hello all
i wanted to make a code to replace all "{RNDCODE}'" in my .pas file , but i want to replace one by one
i don't want to replace all matches with the same new value i want to put new generated value to the every match
i try to do with this code but some times it didn't work as expected .
i'm using "RegExpr" unit
Source := TStringList.Create;
Source.LoadFromFile(filepath);
new := Source.Text;
re := TRegExpr.Create('{RNDCODE}');
try
while re.Exec(new) do
begin
if re.Match[0].Length > 0 then
begin
enc := RandomStuff;
Delete(new,re.MatchPos[0],re.MatchLen[0]);
Insert(enc,new,re.MatchPos[0]);
end;
end;
except on E: Exception do
WriteLn('Error : ',E.Message , ' -- ' , re.Match[0] , ' --- ', ExtractFileNameOnly(filepath));
end;
so if there's any better way to do it , please let me know
thanks