我正在尝试获取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
在此示例中,我期望找到cxRadioGroup2
和cxRadioGroup4
组件。
1°尝试:
我尝试使用正则表达式,但是我不知道如何查找没有Caption
行的事件...使用Notepad ++,我首先尝试捕获每个{{1 }}阻塞,直到他们的TcxRadioGroup
行(缩进相同的end
行)。
end
带有选项^\s*object\s(\w*):\sTcxRadioGroup.*end
它从/gms
到文件的最后object cxRadioGroup1
捕获
2°尝试:
我使用lazy matching和reused the captured white spaces来为每个组件声明匹配正确的end
。
end
和选项^(\s*)object\s(\w*):\sTcxRadioGroup.*?\n\1end
它找到所有/gms
个声明,每个声明从开始到结束。我认为我应该找到一种排除包含TcxRadioGroup
我准备了online example。