输入
下面的代码是c++中对话框的资源声明
LTEXT "Width",IDC_WIDTH_TEXT,203,74,22,10
EDITTEXT IDC_WIDTH_IN,244,73,57,12,ES_AUTOHSCROLL | WS_GROUP
CONTROL "Manually scale instances and paper",IDC_RAD_PSCALE_KEYIN,
"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,89,132,10
CONTROL "Keep drawing instance scale 1.0",IDC_RAD_PSCALE_AUTO,
"Button",BS_AUTORADIOBUTTON,15,104,123,10
CONTROL "Keep drawing paper scale 1.0",IDC_RAD_ISCALE_AUTO,
"Button",BS_AUTORADIOBUTTON,15,119,118,10
期望输出
我想使用Visual 2010查找/替换对话框来处理该信息。
我希望从该声明中提取所有I,并有一个清除的列表,因此,在输入中,我希望得到以下输出:
IDC_WIDTH_TEXT
IDC_WIDTH_IN
IDC_RAD_PSCALE_KEYIN
IDC_RAD_PSCALE_AUTO
IDC_RAD_ISCALE_AUTO1°尝试
如果我使用.*{IDC:i*}.*,那么我可以获得所有这些ID,但是我不会将多行部分从其中提取出来,这是如果我将\1放在替换字段中的输出:
IDC_WIDTH_TEXT
IDC_WIDTH_IN
IDC_RAD_PSCALE_KEYIN
"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,15,89,132,10
IDC_RAD_PSCALE_AUTO
"Button",BS_AUTORADIOBUTTON,15,104,123,10
IDC_RAD_ISCALE_AUTO
"Button",BS_AUTORADIOBUTTON,15,119,118,102°尝试
如果我使用.*{IDC:i*}.*\n.*~({IDC:i*}),则会得到以下缺少IDC_WIDTH_IN的输出
IDC_WIDTH_TEXT
IDC_RAD_PSCALE_KEYIN
IDC_RAD_PSCALE_AUTO
IDC_RAD_ISCALE_AUTO如何才能正确地获得所需的输出?
发布于 2015-05-05 16:34:25
在没有特定于语言/程序的dotall修饰符的情况下,除换行符外,点通常匹配所有内容。
试试这个(演示)。请注意,我的演示中的替换将\n追加到末尾,否则它也会处理新行,并将所有内容放在一行上。
^.*?(IDC\w*)[\s\S]*?(?:$|(,\n.*$))(\n|$)解释:
^ # Anchors to the beginning to the string.
.*? # . denotes any single character, except for newline
# * repeats zero or more times
# ? as few times as possible
( # Opens CG1
IDC # Literal IDC
\w* # Token: \w (a-z, A-Z, 0-9, _)
# * repeats zero or more times
) # Closes CG1
[\s\S]*? # Character class (any of the characters within)
# A character class and negated character class, common expression meaning any character.
(?: # Opens NCG
$ # Anchors to the end to the string.
| # Alternation (NCG)
( # Opens CG2
, # Literal ,
\n # Token: \n (newline)
.* # . denotes any single character, except for newline
$ # Anchors to the end to the string.
) # Closes CG2
) # Closes NCG
( # Opens CG3
\n # Token: \n (newline)
| # Alternation (CG3)
$ # Anchors to the end to the string.
) # Closes CG3https://stackoverflow.com/questions/30058026
复制相似问题