日期:2014-05-17 浏览次数:20432 次
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