I could but "simple" mortals struggle with regular expressions.
Which would mean I should implement some sort of extra logic to detect if the user is using regex or not.
For now, this is a very basic search and replace feature with 2 exceptions :
-if the old pattern (to the right of the "=" in [map] section) is contained in the new pattern (left of "=" in the [map] section, nothing will happen - see why in post.
-order (for now) in which the keys under [map] are read is random (which is not helping )
procedure TfrmDHCPServer.OnReadFile2 (Sender: TObject; var FileName: String) ;
//here we can modify the requested filename on the fly
//before the request gets to the TFTPD
if (h_map<>nil) then //do we have entries in the map section
if keys.Count =0 then exit;
for i:=0 to keys.Count -1 do //lets loop thru map entries
if pos(lowercase(keys [i]),lowercase(filename))>0 then //we have a match
if pos(lowercase(h_map.GetString(keys [i])),lowercase(filename))=0 then //lets replace only if filename does not contain our new string
filename:=StringReplace(filename,keys [i],h_map.GetString(keys [i]),[rfIgnoreCase]); //NOT rfReplaceAll
end;//if pos(h_map.GetString(keys [i]),filename)=0 then
break; //we stop it there as we had a match, whether we actually modified the filename or not
end;//if pos(keys [i],filename)>0
end;//for i:=0 to keys.Count -1 do
end;//if (h_map<>nil) then