Help with Regex to parse dlg template controls

P

pepethecow

I hope this is the appropriate group for this question--the regex
group didn't look too appealing.

I am trying to build a regex to parse out dialog controls from C++ RC
files. Suppose the input text is:

IDD_ADDPRINTDLG DIALOGEX 0, 0, 284, 87
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
CONTROL "Color",IDC_COLOR,"Button",BS_AUTORADIOBUTTON,
11,68,33,14
CONTROL "Grayscale ""Quoted Text
""",IDC_GRAYSCALE,"Button",BS_AUTORADIOBUTTON,50,68,47,14
CONTROL "Faxable
Image",IDC_FAX,"Button",BS_AUTORADIOBUTTON,103,68,59,14
GROUPBOX "Printing Options",IDC_PDOPTIONS,8,59,271,26
GROUPBOX "Footer Text",IDC_FOOTERBOX,8,4,272,51
EDITTEXT IDC_FOOTER,13,13,262,40,ES_MULTILINE |
ES_WANTRETURN
END

If I use the regex (EDITTEXT|CONTROL|GROUPBOX|LTEXT|PUSHBUTTON|
DEFPUSHBUTTON)\s+("(?<ControlText>.*?)",\s*)?(?<Identifier>\w+),[\v\f
\S]+\n

it finds everything except the EDITTEXT line, which doesn't have the
optional ControlText field. I've stared at this for a few hours now
trying to figure why it can't find it. Any ideas?

Thank you.

-Ben
 
P

pepethecow

I hope this is the appropriate group for this question--the regex
group didn't look too appealing.

I am trying to build a regex to parse out dialog controls from C++ RC
files. Suppose the input text is:

IDD_ADDPRINTDLG DIALOGEX 0, 0, 284, 87
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
CONTROL "Color",IDC_COLOR,"Button",BS_AUTORADIOBUTTON,
11,68,33,14
CONTROL "Grayscale ""Quoted Text
""",IDC_GRAYSCALE,"Button",BS_AUTORADIOBUTTON,50,68,47,14
CONTROL "Faxable
Image",IDC_FAX,"Button",BS_AUTORADIOBUTTON,103,68,59,14
GROUPBOX "Printing Options",IDC_PDOPTIONS,8,59,271,26
GROUPBOX "Footer Text",IDC_FOOTERBOX,8,4,272,51
EDITTEXT IDC_FOOTER,13,13,262,40,ES_MULTILINE |
ES_WANTRETURN
END

If I use the regex (EDITTEXT|CONTROL|GROUPBOX|LTEXT|PUSHBUTTON|
DEFPUSHBUTTON)\s+("(?<ControlText>.*?)",\s*)?(?<Identifier>\w+),[\v\f
\S]+\n

it finds everything except the EDITTEXT line, which doesn't have the
optional ControlText field. I've stared at this for a few hours now
trying to figure why it can't find it. Any ideas?

Thank you.

-Ben


As usual, talking about it helped me figure it out on my own. The
problem was with the spaces around the pipe in the EDITTEXT line...
 
Top