【发布时间】:2015-09-01 10:22:58
【问题描述】:
我想捕获匹配的花括号。
例如:
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"
如果{ 出现在文本中,我知道它会忽略。但我不知道如何创建一个正则表达式来单独获取匹配的花括号。
【问题讨论】:
-
请大家帮我解答stackoverflow.com/questions/33841196/…的问题