要可以匹配大概有三种类型的。
1.http://www.aa.com/inx.php 大概这样
2.http://localhost:80/inx.php 大概这样
3.http://127.0.0.1:80/inx.php大概这样
1.http://www.aa.com/inx.php 大概这样
2.http://localhost:80/inx.php 大概这样
3.http://127.0.0.1:80/inx.php大概这样
http://localhost:80/inx.php 大概这样
$str='http://127.0.0.1:80/inx.php';
if(preg_match('/http:\/\/[^\/]+\/\w+\.\w+/',$str))
echo 'yes';
else
echo 'no';
1.http://www.aa.com/inx.php 大概这样
2.http://localhost:80/inx.php 大概这样
3.http://127.0.0.1:80/inx.php大概这样
TXT;preg_match_all('#\w{3,4}://[\w./:]+#s', $s, $r);
print_r($r[0]);
Array
(
[0] => http://www.aa.com/inx.php
[1] => http://localhost:80/inx.php
[2] => http://127.0.0.1:80/inx.php
)