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

请问一个正则匹配有关问题

WBOY
Release: 2016-06-13 12:07:52
Original
826 people have browsed it

请教一个正则匹配问题
有一段内容

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


请教怎么用正则匹配函数preg_replace,把这段内容中的‘啦啦啦啦’消除,只留下字符。
注:链接中‘1.html'和“啦啦啦啦”是随机出现的
------解决思路----------------------
echo preg_replace('#<a.+?</a>#s', '', $neirong);
Copy after login

------解决思路----------------------
    <?php  <br />	<br />    $string = 'aaaaaaaaaaaaaa<a href="1.html" target="_blank">啦啦啦啦</a>ddddddddddddddd';<br />	 <br />	echo preg_replace('/<a href="(?:.*)" target="_blank">(.*)<\/a>/Ui', '\1', $string);  <br /><br />    ?>
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