php正则链接,php正则链接里面的数据
文章标签
in_array()
本文目录一览:
- 1、php正则获取href的链接
- 2、php正则表达式去除超链接。
- 3、php正则表达式提取链接
php正则获取href的链接
使用正则中的子模式,按给出的代码匹配的话大概是这样
$pattern='/href=\"([^(\})]+)\"/';
然后使用preg_match或者preg_match_all如果替换的话使用preg_replace即可
php正则表达式去除超链接。
preg_replace正则匹配,去除所有a链接地址,并且保留里面a里面的内容
preg_replace(“#a[^]*(.*?)/a#is”, “$1”,$body);
ereg_replace正则匹配:
ereg_replace(“]*|/a”,””,$content);
ereg_replace函数匹配以”a “开头,中间除以外的所有字符,再以结尾的字符串或匹配””字符。匹配到的字符串赋为空。

php正则表达式提取链接
$preg='/a .*?href="(.*?)".*?/is';
$str ='a href="链接"123/aa href="链接" target="_blank"345/aa target="_blank" href="链接"678/a';
preg_match_all($preg,$str,$match);
var_dump($match);
版权声明
本文仅代表作者观点,不代表Code前端网立场。
本文系作者Code前端网发表,如需转载,请注明页面地址。
code前端网