检查下代码
<
[SettingProperty("Base chance (bandits), %/day", 0f, 1f, false, "Base chance that a prisoner will escape from bandits")]
[SettingProperty("Base chance, %/day", 0f, 1f, false, "Base chance that a prisoner will escape from noble")]
正则模式
< [SettingProperty("Base chance (bandits), %/day", 0f, 1f, false, "Base chance that a prisoner will escape from bandits")]
[SettingProperty("Base chance, %/day", 0f, 1f, false, "Base chance that a prisoner will escape from noble")]
[SettingProperty("Price change rate, days", 0f, 100f, false, "Captors will ask half as much as [value] days before, and ransomers will agree to pay twice as much.")]
1,正则表达式 SettingProperty(\([\s\S]*?)\)]
分析上面的代码结构 发现其都是以[SettingProperty( 开头 以 )] 结尾 至于为什么不是以[SettingProperty开头 以 ] 结尾.看第三行代码 出现了两个]符号,会导致正则表达式提取错误.必须唯一出现才能正确取出
第三行代码如果以SettingProperty( 开头 以 ] 结尾 提取的结果是这样的 Price change rate, days", 0f, 100f, false, "Captors will ask half as much as [value
第三行代码如果以SettingProperty( 开头 以 )] 结尾 提取的结果是这样的 "Price change rate, days", 0f, 100f, false, "Captors will ask half as much as [value] days before, and ransomers will agree to pay twice as much."
那么哪个正确就很明显了
那么我们想提取字符串的正则表达式就是 SettingProperty(\([\s\S]*?)\)] 正则表达式这块我也不是很精通.有兴趣的朋友自行百度