要可以匹配大概有三种类型的。
1.http://www.aa.com/inx.php 大概这样
2.http://localhost:80/inx.php 大概这样
3.http://127.0.0.1:80/inx.php大概这样

解决方案 »

  1.   

    用的php的preg_replace,第2,3种也能匹配
      

  2.   

    就是能够匹配这种url的
    http://localhost:80/inx.php 大概这样
      

  3.   

    上面的没有问题啊。
    $str='http://127.0.0.1:80/inx.php';
    if(preg_match('/http:\/\/[^\/]+\/\w+\.\w+/',$str))
      echo 'yes';
    else
      echo 'no';
      

  4.   

    $s = <<< TXT
    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
    )