如何在Delphi DFM组件声明中搜索缺少的属性?

时间:2019-10-11 12:23:30

标签: regex dfm

我正在尝试获取TcxRadioGroup类的所有偶然事件,这些事件在Delphi DFM文件中没有Caption属性的值。

我必须在具有成千上万种形式的大型小组项目中执行此操作。由于这个原因,我正在寻找一种可以在多个文件上使用的解决方案(我认为在 Notepad ++ 中使用 RegEx ,但是我对任何其他解决方案都持开放态度)< / p>

示例:

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 494
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object cxRadioGroup1: TcxRadioGroup
    Left = 0
    Top = 0
    Align = alTop
    Caption = 'cxRadioGroup1'
    Properties.Items = <>
    TabOrder = 0
    ExplicitLeft = 24
    ExplicitTop = 16
    ExplicitWidth = 185
    Height = 105
    Width = 635
  end
  object cxRadioGroup2: TcxRadioGroup
    Left = 0
    Top = 389
    Align = alBottom
    Properties.Items = <>
    TabOrder = 1
    ExplicitTop = 293
    Height = 105
    Width = 635
  end
  object Panel1: TPanel
    Left = 200
    Top = 111
    Width = 257
    Height = 265
    Caption = 'Panel1'
    TabOrder = 2
    object cxRadioGroup3: TcxRadioGroup
      Left = 8
      Top = 16
      Caption = 'cxRadioGroup3'
      Properties.Items = <>
      TabOrder = 0
      Height = 105
      Width = 185
    end
    object cxRadioGroup4: TcxRadioGroup
      Left = 8
      Top = 144
      Properties.Items = <
        item
          Caption = 'item 1'
        end
        item
          Caption = 'item 2'
        end>
      TabOrder = 1
      Height = 105
      Width = 185
    end
  end
end

在此示例中,我期望找到cxRadioGroup2cxRadioGroup4组件。


1°尝试:

我尝试使用正则表达式,但是我不知道如何查找没有Caption行的事件...使用Notepad ++,我首先尝试捕获每个{{1 }}阻塞,直到他们的TcxRadioGroup行(缩进相同的end行)。

end 带有选项^\s*object\s(\w*):\sTcxRadioGroup.*end

它从/gms到文件的最后object cxRadioGroup1捕获


2°尝试:

我使用lazy matchingreused the captured white spaces来为每个组件声明匹配正确的end

end和选项^(\s*)object\s(\w*):\sTcxRadioGroup.*?\n\1end

它找到所有/gms个声明,每个声明从开始到结束。我认为我应该找到一种排除包含TcxRadioGroup

的人的方法

我准备了online example

0 个答案:

没有答案