Home  >  Article  >  Backend Development  >  请教一个正则匹配问题

请教一个正则匹配问题

WBOY
WBOYOriginal
2016-06-23 13:47:37731browse

有一段内容

$neirong='aaaaaaaaaaaaaa<a href="1.html" target="_blank">啦啦啦啦</a>ddddddddddddddd';


请教怎么用正则匹配函数preg_replace,把这段内容中的‘啦啦啦啦’消除,只留下字符。
注:链接中‘1.html'和“啦啦啦啦”是随机出现的


回复讨论(解决方案)

echo preg_replace('#<a.+?</a>#s', '', $neirong);

    <?php  	    $string = 'aaaaaaaaaaaaaa<a href="1.html" target="_blank">啦啦啦啦</a>ddddddddddddddd';	 	echo preg_replace('/<a href="(?:.*)" target="_blank">(.*)<\/a>/Ui', '\1', $string);      ?>
   

可以了,非常感谢两位

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