请问一个匹配各种url的正则表达式

WBOY
Release: 2016-06-13 13:28:57
Original
912 people have browsed it

请教一个匹配各种url的正则表达式
要可以匹配大概有三种类型的。
1.http://www.aa.com/inx.php 大概这样
2.http://localhost:80/inx.php 大概这样
3.http://127.0.0.1:80/inx.php大概这样

------解决方案--------------------
哪里不满足。你的代码怎么写的?
------解决方案--------------------
上面的没有问题啊。

PHP code
$str='http://127.0.0.1:80/inx.php';
if(preg_match('/http:\/\/[^\/]+\/\w+\.\w+/',$str))
  echo 'yes';
else
  echo 'no'; <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template