0
嗨我有这个正则表达式来匹配ursl,但我也需要匹配子域名。preg_match_all正则表达式子域名
public function getUrls($url){
preg_match_all("#(www\.|https?:\/\/){1}[a-zA-Z0-9]{2,}\.[a-zA-Z0-9]{2,}(\S*)#i",$url, $matches);
return $matches[0];
}
这场比赛http://domain.com但不http://sub.domain.com
不知道如何使它发挥作用?
看一看:http://stackoverflow.com/questions/288810/get-the-subdomain-from-a-url – Birei