In new versions of GExperts, the grep utility now supports more 'expert' expressions.
I have not yet found a way to locate empty try ... except blocks in Delphi sources using regular expressions, how could I do this with the GExperts grep tool?
In new versions of GExperts, the grep utility now supports more 'expert' expressions.
I have not yet found a way to locate empty try ... except blocks in Delphi sources using regular expressions, how could I do this with the GExperts grep tool?
I doubt that GExperts Regex functionality allows you to search beyond line delimiters.
If you don't mind using a component like TPerlRegEx, following code should get you started to roll your own search.
var
emptyExceptBlock: TPerlRegEx;
Results: TStringList;
emptyExceptBlock := TPerlRegEx.Create(nil);
emptyExceptBlock.RegEx := except\s+((//.*|/\*.*\*/|\(\*.*\*\))\s+)*end;
emptyExceptBlock.Options := [preExtended];
emptyExceptBlock.Subject := LoadFromFile('YourFile.pas');
Results := TStringList.Create;
if emptyExceptBlock.Match then begin
repeat
Results.Add(emptyExceptBlock.MatchedExpression);
until not emptyExceptBlock.MatchAgain;
end;
There is a tool called Insert Auto Todo (which is not part of GExperts, I think I got it from CodeCentral) that automatically inserts todos into empty begin/end blocks. Maybe that's what you want?