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

请教一个正则匹配问题

WBOY
Release: 2016-06-23 13:47:37
Original
789 people have browsed it

有一段内容

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


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


回复讨论(解决方案)

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

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

可以了,非常感谢两位

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