我想要捕捉匹配的大括号。
例如:
Some example text with \added[author]{text with curly braces{some text}..}
Some example text with \added[author]{text without curly braces}
Some example text with \added[author]{text with {}and {} and {}curly braces{some text}..}
Some example text with \added[author]{text with {}and {} and {}curly braces{some text}..} and extented text with curly braces {}
期望输出结果:
Some example text with text with curly braces{some text}..
Some example text with text without curly braces
Some example text with text with {}and {} and {}curly braces{some text}..
Some example text with text with {}and {} and {}curly braces{some text}.. and extented text with curly braces {}
也就是说,我想捕获\added[] {
和}
之间的文本(与其相关的右花括号)。我的正则表达式存在问题,我不知道如何捕获相关花括号之间的文本。
我尝试了以下方法:
"/\\\\added\\[.*?\\]{(.[^{]*?)}/s"
我知道它会忽略文本中的 {
。但是我不知道如何创建一个正则表达式来匹配花括号。