日期:2014-05-17  浏览次数:20432 次

二次获取的正则表达式怎么写
字符串:aaa A.B(aafdsaaaaaaa);aaadcsafdsaaaaa c.B(aaaaadaaaa);aadfsa.D(aafdse);aaaaa A.B(aaaascaaaaa);aafdsaa

想替换“A.B(*);”里面的“);”部份,

我想要的思路是先获取到“A.B(aafdsaaaaaaa);”,再从这里面获取“);”,不知道这样二次获取的正则表达式怎么写

------解决方案--------------------
Like this?
C# code
string tempStr = @"aaa A.B(aafdsaaaaaaa);aaadcsafdsaaaaa c.B(aaaaadaaaa);aadfsa.D(aafdse);aaaaa A.B(aaaascaaaaa);aafdsaa";
            string replaceStr = "*";
            tempStr = Regex.Replace(tempStr,@"(?<=\w+?\.\w+?\([^)]+?)\);",replaceStr);
            //aaa A.B(aafdsaaaaaaa*aaadcsafdsaaaaa c.B(aaaaadaaaa*aadfsa.D(aafdse*aaaaa A.B(aaaascaaaaa*aafdsaa

------解决方案--------------------
string a = "字符串:aaa A.B(aafdsaaaaaaa);aaadcsafdsaaaaa c.B(aaaaadaaaa);aadfsa.D(aafdse);aaaaa A.B(aaaascaaaaa);aafdsaa";
a = Regex.Replace(a,@"(?<=A.B\([^\(]*?)\)", "",RegexOptions.IgnoreCase);

//结果:
字符串:aaa A.B(aafdsaaaaaaa;aaadcsafdsaaaaa c.B(aaaaadaaaa);aadfsa.D(aafdse);aaaaa A.B(aaaascaaaaa;aafdsaa