I'm trying to get all occurrencies of the TcxRadioGroup
class which have not a value for the Caption
property in Delphi DFM files.
I have to do this in a big groupproject with thousands of forms. For this reason I'm looking for a solution which can work on multiple files (I thought to use a RegEx in Notepad++ but I'm open to any other solution)
Example:
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
In this example, I'm expecting to find cxRadioGroup2
and cxRadioGroup4
components.
1° Attempt:
I've tried to use a regular expression but I don't know how to find occurences which have not the Caption
line... Using Notepad++, I've started by trying to catch each TcxRadioGroup
block until their end
line (the end
line which has the same indentation).
^\s*object\s(\w*):\sTcxRadioGroup.*end
with options /gms
It catches from object cxRadioGroup1
to the last end
of the file
2° Attempt:
I've used lazy matching and reused the captured white spaces in order to match the right end
for each component declaration.
^(\s*)object\s(\w*):\sTcxRadioGroup.*?\n\1end
with options /gms
It finds all TcxRadioGroup
declarations, each one from its beginning to its end. I think I should find a way to exclude the ones who contains \1 Caption =
I've prepared an online example.