js正则截取url的域名

js正则截取url的域名:

  

var urlReg = /[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/;  

var p="http://p2.playsnail.net/album/0/0/0/20/5/200506/13505/S_14028.jpg"

url2=p.replace(urlReg,"p1.playsnail.net")

alert(url2)

 

你可能感兴趣的:(url)