文章目录[隐藏]
如例:
http://bbs.gaodaima.com/topics/new?forum_id=PHP
http://www.bdyy.cc/detail/?20236.html
http://www.qq.com/html/?20236.html?id=88888
preg_match(‘/(http:\/\/本文来源gaodai$ma#com搞$$代**码)网8搞代gaodaima码)(.*)(\/)/’,$rrr,$matches);
如何分别正则出:
bbs.gaodaima.com
http://www.bdyy.cc
http://www.qq.com
回复讨论(解决方案)
$s=<<<txthttp://bbs.gaodaima.com/topics/new?forum_id=PHPhttp://www.bdyy.cc/detail/?20236.htmlhttp://www.qq.com/html/?20236.html?id=88888txt;preg_match_all('/http:\/\/([^\/]+)\//s',$s,$matches);print_r($matches[1]);
Array
(
[0] => bbs.gaodaima.com
[1] => http://www.bdyy.cc
[2] => http://www.qq.com
)
preg_match(‘/http:\/\/([^\/]*)/i’,$rrr,$matches);