正则表达式匹配最外层大括号里面的内容;匹配最内层大括号里面的内容

不管什么都要记录一下,也是服了我自己

对正则表达式不了解,遇到一个问题需要匹配最外层大括号的内容,绞尽脑汁,无果

后来解决了:

female{{initiator} updated {person}’s role to {role}}

最外层正则表达式:

(?<={).*(?=})
共找到 1 处匹配:
{initiator} updated {person}’s role to {role}

最内层正则表达式:

{[^{}]+}
共找到 3 处匹配:
{initiator}
{person}
{role}
MrNou
原文地址:https://www.cnblogs.com/yangsirc/p/8243528.html