我是正则表达式的新手,并希望使用一个来搜索我们的源代码控件,以查找遵循特定枚举值的代码块中的文本.即:
/(\/{2}\@debug)(.|\s)*?(\/{2}\@end-debug).*/
var junk = dontWantThis if (junk) {dont want this} if ( **myEnumValue** ) **{ var yes = iWantToFindThis if (true) { var yes2 = iWantThisToo } }**
var junk2 = dontWantThis if (junk) {dont want this}
var stuff = dontWantThis if (junk) {dont want this} if ( enumValue ) { wantToFindThis }
var stuff = iDontWantThis if (junk) {iDontWantThisEither}
Run Code Online (Sandbox Code Playgroud)
我知道我可以(\{(/?[^\>]+)\})用来查找块,但我只想要第一个包含我想要的枚举值的代码块.我也注意到use使用(\{(/?[^\>]+)\})了第一个{和最后一个},它不会对后续组合{}.
谢谢!
蒂姆
| 归档时间: |
|
| 查看次数: |
196 次 |
| 最近记录: |