<script>
var req = /^http:\/\/[^\.]+\.([^\/]+).*?$/;
var urls = [];urls.push("http://paca.sina.com.cn/test1/test2.php?id=123456");
urls.push("http://ecer.163.com/test1/test2.php?id=123456");alert(urls[0].replace(req,"$1"));
alert(urls[1].replace(req,"$1"));
</script>
var s1="http://paca.sina.com.cn/test1/test2.php?id=123456";
var s2="www.baidu.com/mp3/?id=1";
var oReg=/^(?:http:\/\/)?(\w+(\.\w+)+)(?=\/|$)/i;s1.match(oReg);
alert(RegExp.$1);s2.match(oReg);
alert(RegExp.$1);