我正在尝试匹配大括号内的每一行,并且我正在努力捕捉我想要的内容。举个例子,如果我有这个文本:
{ 这是一条线, 这 = 另一行, 这是第三行! 这确实是另一条线 }, 第二轮:{ 我们现在在第二对括号上, 这是最后一行。 }
然后我想匹配并捕获总共六行:
this is a line,
this = another line,
this is the third line!
this is, indeed, another line
we're now on the second pair of brackets,
and this is the final line.
到目前为止,我目前的想法是尝试匹配“大括号”->“任何东西”->“行”->“任何东西”->“大括号”,即这样的:
{(?s)[^}]*(^([^}^\n]+)$)(?s)[^}]*}
但这仅匹配每对花括号中的一行,而不是每一行。
我该怎么做呢?谢谢。
编辑:更新了示例以在一个左大括号和不同的空格之前包含前面的文本。