【发布时间】:2012-01-18 13:30:21
【问题描述】:
我正在使用以下正则表达式来查找组
string pattern = @"(?<member>(?>\w+))\((?:(?<parameter>(?:(?>[^,()""']+)|""(?>[^\\""]+|\\"")*""|@""(?>[^""]+|"""")*""|'(?:[^']|\\')*'|\((?:(?<nest>\()|(?<-nest>\))|(?>[^()]+))*(?(nest)(?!))\))+)\s*(?(?=,),\s*|(?=\))))+\)";
来自像
这样的表达式string Exp = "GetValue(GetValue(GetValue(1 + 2) * GetValue(3 * 4)) / GetValue(GetValue(5 * 6) / 7) / 8)";
我得到以下组:
a) GetValue(GetValue(1 + 2) * GetValue(3 * 4))
b) 获取值(GetValue(5 * 6) / 7)
我得到了所有组,但外部组 (GetValue(.... / 8)) 没有得到???
模式中可能有什么问题??
【问题讨论】:
-
我尝试创建一个正则表达式,但它根本不匹配:regexr.com?2voqv
-
你能进一步解释一下想要的结果吗?具体来说,您希望在每个组中捕获什么:成员、参数、嵌套、-nest。