<html>
<body>
<script type="text/javascript">
var srw=",a(,(b,(c,))d),";
var pattern = /\((.*)\)/gi;
newstr=srw.replace(pattern , "");
document.write("去掉最外层括号里的内容:"+srw+"<br />"+newstr+"<br />")
var newstr=srw.match(pattern);
document.write("取最外层括号里的内容:"+srw+"<br />"+newstr+"<br />")
pattern = /\([^()]+\)/gi;
var newstr=srw.match(pattern);
document.write("取最里层括号里的内容:"+srw+"<br />"+newstr+"<br />")
pattern = /^,/gi;
newstr=srw.replace(pattern , "");
document.write("去掉最左边的逗号:"+srw+"<br />"+newstr+"<br />")
pattern = /,$/gi;
newstr=srw.replace(pattern , "");
document.write("去掉最右边的逗号:"+srw+"<br />"+newstr+"<br />")
pattern =/\(|\)|,/gi;
newstr=srw.replace(pattern , "");
document.write("替换:"+srw+"<br />"+newstr+"<br />")
</script>
</body>
</html>