<script type="text/javascript">
// var str='http://taobao.com/?id=123456780';
// var str='http://taobao.com/&id=123456780'
var str='http://taobao.com/?shid=123456780&id=0000000'
var re=/(&id=)([0-9]{5,20})/g;
var re2=/([?]id=)([0-9]{5,20})/g;
var re3=/([0-9]{5,20})/g;
newre=str.match(re)
newre2=str.match(re2)
if (newre==null && newre2==null) {alert( "商品id不存在" );}else{
if (newre!=null) {
itemurl=newre[0];
itemurl=itemurl.match(re3);
itemurl=itemurl[0]
alert(itemurl)
}else{
itemurl=newre2[0];
itemurl=itemurl.match(re3);
itemurl=itemurl[0]
alert(itemurl)
}
}
</script>