Home >Backend Development >PHP Tutorial >请问一个匹配各种url的正则表达式

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

WBOY
WBOYOriginal
2016-06-13 10:26:10940browse

请教一个匹配各种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>
Statement:
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