我想用支持正则表达式的程序搜索250个文件,但我不知道如何构建查询。
这是一个示例文件:
//////////////////////////////Crown Area Effects///////////////////////////////
// Super Spies
DbAreaEffectInfo SuperSpies
{
name = text_carea_sprspies_name
desc = text_carea_sprspies_desc
effects = [
// scale sabotage super-effect duration
EffectDuration {
range = SpaceTime
player = Self
// which effect's duration is this scaling
effect = "SabotageBuilding"
scale = 1.25
}
EffectDuration {
range = SpaceTime
player = Self
// which effect's duration is this scaling
effect = "ImprovedSabotageBuilding"
scale = 1.25
}
EffectSpeed {
range = Global
mask = Spies
player = Self
// 25% faster
scale = 1.25
}
EffectMaxHitPoints {
range = Global
mask = Spies
player = Self
// 25% more hit points
scale = 1.25
}
EffectVisualGlow {
range = Global
mask = Spies
player = Self
GlowType = Good
OwnerOnly = true
Icon = icon_crown_superspies_s
Tooltip = text_carea_sprspies_name
VTooltip = vtt_power_unitinfo_SuperSpies
}
EffectIsACrown {
range = Global
mask = Spies
player = Self
crownType = kCrownType_Imperial
}
]
}
我希望找到像这样的模式:
<ANYTHING, EVEN NULL>//<ANYTHING, EVEN NULL><MyString><AnyThing, EVEN NULL>
例如:
<anything>//<anything>super<anything>
哪会产生这样的结果:
// scale sabotage super-effect duration
什么样的正则表达式查询会给我想要的结果?
提前感谢您的时间和精力!
编辑:
我正在使用有效文件搜索 - http://www.sowsoft.com/search.htm
答案 0 :(得分:1)
标准正则表达式通配符为.
(对于一个字符)。任意重复由*
表示。所以这应该适合你:
~//(.*)super(.*)~
根据您的正则表达式引擎,您可能/必须省略分隔符~
。此外,由于默认情况下.
与换行符不匹配,因此第二个通配符将始终显示在该行的末尾,而super
必须与//
显示在同一行。< / p>
答案 1 :(得分:0)
答案 2 :(得分:0)
^\s*//.*?(STRINGYOUWANTTOSEARCHFOR).*$
假设pcre / perlre风格。
在perlre中,使用
^\s*//.*?(\QSTRINGYOUWANTTOSEARCHFOR\E).*$
防止您正在寻找的字符串中出现奇怪的解释
其他正则表达式引擎/ flavor有不同的语法,请参阅http://www.regular-expressions.info/reference.html进行比较