Maybe?
program project1;
{$mode objfpc}{$H+}
uses
Classes, RegExpr, sysutils;
function RemoveTADOQueryEmptyParameters(AFileName: string): string;
var
sl: TStringList;
begin
sl := TStringList.Create;
try
sl.LoadFromFile(AFileName);
Result := ReplaceRegExpr(
'(.+object [^:]+: TADOQuery[^:]+[\r\n]+)(\s+Parameters = <>[\r\n]+)(\s+SQL.Strings = .+)',
sl.Text,
'$1$3', true);
finally
sl.Free;
end;
end;
begin
try
WriteLn(RemoveTADOQueryEmptyParameters('your.dfm'));
except
on e: exception do writeLn(e.Message);
end;
ReadLn;
end.
Explaining the expression:
want to remove
spacesParameters = <> followed by
new line marker:
(
\s+Parameters = <>[\r\n]+)
It has to be preceded by:
object anything except a colon: TADOQueryother properties (do not include a colon)new line marker:
(.+
object [^:]+: TADOQuery[^:]+[\r\n]+)
*Not sure about this part, depends if this is really the next property always*
And it should be followed by SQL.Strings property:
(\s+SQL.Strings = .+)
The replacement is the 1
st group and the 3
rd group:
$1$3
the 2
nd group is what gets deleted.
There are other methods to approach this problem.