我怎样才能找到所有空的尝试...除了带有GExperts grep的块?

mjn*_*mjn 1 delphi grep exception gexperts

在新版本的GExperts中,grep实用程序现在支持更多"专家"表达式.

我还没有找到一种方法来定位空的try ...除了使用正则表达式的Delphi源代码块,我怎么能用GExperts grep工具呢?

Lie*_*ers 5

我怀疑GExperts Regex功能允许您搜索超出行分隔符.

如果您不介意使用像TPerlRegEx这样的组件,下面的代码应该让您开始自己的搜索.

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;
Run Code Online (Sandbox Code Playgroud)