现有下列url:http://www.abc.comhttp://www.def.com/https://www.ghl.com/我该如何做把上面这三个挨个匹配出真剩下中间部分,例如www.abc.com
看看我下面的例子代码:<?php$s='http://www.abc.com http://www.def.com/ https://www.ghl.com/';if (preg_match_all('#https?://(.*?)($|/)#m', $s, $r)) print_r($r[1]);?>执行的结果是:E:\ygb>php a.phpArray( [0] => www.abc.com [1] => www.def.com [2] => www.ghl.com)