php正则怎么去掉href
本文操作环境:Windows7系统、php7.1、Dell G3电脑。
php正则怎么去掉href?
问题描述:
php 正则表达式 去除href及数据
要把这段<a target="_blank" href="./Itemxteal_8000-0000_1.htm">8000-0000</a>
替换为<a target="_blank" >8000-0000</a>
链接不唯一 就是去掉href=“XXXXX”
要怎么写??
实现方法:
<?php $string = '<a target="_blank" href="./Itemxteal_8000-0000_1.htm">8000-0000</a>'; preg_match('/href\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([^"\'>\s]+))/is', $string,$matches); //print_r($matches); echo str_replace($matches[0], '', $string); ?>
版权声明:
作者:后浪云
链接:https://www.idc.net/help/7789/
文章版权归作者所有,未经允许请勿转载。
THE END