日期:2012-06-10  浏览次数:20521 次

比如域名是aiyiweb.com,正则表达式如下:
 
$S = 'http://www.aiyiweb.com/'
$domain = array('com','cn','name','org','net');
$SS = $S;
$dd = implode('|',$domain);
$SS = preg_replace('/(.*)((\w+)(\.('.$dd.'))*\.('.$dd.'))$/iU','$2',$SS);
echo $SS ;