Home > Backend Development > PHP Tutorial > 求内容去掉链接解决方法

求内容去掉链接解决方法

WBOY
Release: 2016-06-13 13:28:25
Original
848 people have browsed it

求内容去掉链接
如下内容
这个数字想必让很多妈妈们都无比惊讶。快来看看看秘诀>>>-[-/a>



来了看看
这个数字想必让很多妈妈们都无比惊讶。看看秘诀>>>-[-/a>


-----------------------------------------------
我要去掉
-]- 中间的链接文字保留 -[-/a>
------------------------------------------
如下结果

这个数字快来看看看秘诀>>>-[-/a>

来了
看看
这个数字。


------解决方案--------------------
楼主确定
HTML code
<a href="http://www.csdn.com" target="_blank" style="color: #ff0000">快来看</a><a href="http://www.jianfei.com" target="_blank"><u>看看</u></a>秘诀>>>-[-/a>
<br><font color="#e78608">------解决方案--------------------</font><br>完全没看懂
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code

$result = preg_replace('/<a>]*-\]-.+-\[-\/a>/','',$content);
$result = preg_replace('/</a><a>]*>.+/','',$result);
echo $result;
<br><font color="#e78608">------解决方案--------------------</font><br></a>
Copy after login
探讨

PHP code

$result = preg_replace('/
]*-\]-.+-\[-\/a>/','',$content);
$result = preg_replace('/
]*>.+/','',$result);
echo $result;

------解决方案--------------------
PHP code
$s = <u>看看</u>
Copy after login
-[-/a>
TXT; echo preg_replace('/(?:-\]-)(.+)(?:-\[-)/e', 'strip_tags("$0")', $s);
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