嵌套的正则表达式怎么写?
字符串:aaa A.B(aafdsaaaaaaa);aaadcsafdsaaaaa c.B(aaaaadaaaa);aadfsa.D(aafdse);aaaaa A.B(aaaascaaaaa);aafdsaa
想替换“A.B(*);”里面的“);”部份,(注:不要叫我用Replace什么的,我不是在程序里用,是在Dreamweaver里用正则批量替换页面里的内容,页面非常多。)
我想要的思路是先获取到“A.B(*);”,再从这里面获取“);”,也就是类似子查询这样,不知正则嵌套查找怎么写
------解决方案--------------------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
------解决方案--------------------Dreamweaver 没有替换功能吗。。
------解决方案-------------------- <script language="javascript" type="text/javascript">
var str = "aaa A.B(aafdsaaaaaaa);aaadcsafdsaaaaa c.B(aaaaadaaaa);aadfsa.D(aafdse);aaaaa A.B(aaaascaaaaa);aafdsaa";
str = str.replace(/([^)]*)\);/g, "$1\n");
alert(str);
</script>