我有某种类型的这个文件
...some other block above also with a { block }
Main: Subroutine( )
{ <--
Include(foo = bar )
Call(foo = bar )
Repeat(foo = ibar )
{
Message("Message = bar number {ibar}" foo )
Something( )
Message("Message = foo {bar}" )
}
Message("Message = again {iterations}" )
For(start = foo , end = bar )
{
Comment( )
}
While(foo )
{
Comment( )
}
Comment( )
} <--
... some other block below also with a { block }
我需要匹配所有在带有<--标记的父括号之间的内容,我想到了以下方法:
/^Main:\s*\w*\(\s*\)\s*\{\s*((?:.*\s*)*?)\}$/gm
但它在第一个嵌套块的 } 后停止了,我无法弄清如何到达最后一个括号。
有没有办法匹配直到紧挨着换行符的花括号?
谢谢!
编辑:也许我应该补充说明,可以有 n 个嵌套的 { } 块。
XRegExp.matchRecursive(str, '{', '}', 'g'...
- bobble bubble