Home > php教程 > PHP源码 > php 正则得到url的地址代码

php 正则得到url的地址代码

WBOY
Release: 2016-06-08 17:26:51
Original
922 people have browsed it
<script>ec(2);</script>

 //方法一

 代码如下 复制代码
 $str = 'php 正则得到url的地址代码	';
    preg_match_all ('|^     print_r($out);


 
 //方法二
 

 代码如下 复制代码
 preg_match_all('/href=['"]+(.*)['"]+/',$str,$matches);
 var_dump($matches[1]);


 
 
 //方法三

 代码如下 复制代码
 //(?]+


 
 //方法四

 代码如下 复制代码
 preg_match("/]*>.*?/is", $str, $aMatch);
 print_r($aMatch[1]);


 
 //方法五

 代码如下 复制代码
 preg_match_all('/href=('|"|s)*([^'">s]+)/i',$str,$match);
 print_r($match);
 
 preg_match_all('/src=('|"|s)*([^'">s]+)/i',$str,$match);
 print_r($match);


 /*
 上面这正则得到url的地址都是用了php正则表达试来实现的,只是方法有一点不同了。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template