Home > Backend Development > PHP Tutorial > 高手帮忙看看这个正则怎么写

高手帮忙看看这个正则怎么写

WBOY
Release: 2016-06-13 13:09:59
Original
748 people have browsed it

高手帮忙看看这个正则如何写?
 

内容1

 

内容2

 

内容3

 
 
问用php把

删除,并且把

变成
,需要连一起处理。完成后应该是 
 
内容1
 
内容2
 
内容3
 

自己写的正则不能把删掉不知道怎么回事,请教一下高手

------解决方案--------------------
PHP code


$str = "<span>
<p>内容1</p>
<p align='\"center\"'>内容2</p>
<p style='\"text-align:' center align='\"left\"'>内容3</p>
</span> ";
//自己稍微查下正则的高级用法吧 你匹配不出来估计是对正则贪婪模式不理解
echo preg_replace('/<p.>(.*)/i','\\1<br>',$str); <div class="clear">
                 
              
              
        
            </div></p.>
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