正则表达式如何将带有标识的元素里的内容批量替换?

WBOY
Release: 2016-06-23 14:27:15
Original
1085 people have browsed it



        
  • 11111111111

  •         
  • 22222222222

  •         
  • 33333333333

  •     





    
11111111111

        
22222222222

    




  • 11111111111

  • 22222222222

  • 33333333333




11111111111
22222222222
33333333333




正则表达式,如何将带有 class="label" 标识的元素里的内容批量替换?

回复讨论(解决方案)

你没有说明修改成什么,就假定删除吧!

$s =<<< TXT<div class="label"><dl>    	<dt>11111111111</dt>        <dd>22222222222</dd>    </dl></div><ul class="label"><li>11111111111</li><li>22222222222</li><li>33333333333</li></ul><p class="label"><a href="#">11111111111</a><a href="#">22222222222</a><a href="#">33333333333</a></p>TXT;echo preg_replace('#(<(\w+).+?class="label"\s*>).+?(</\2>)#s', '$1$3', $s);
Copy after login
<div class="label"></div><ul class="label"></ul><p class="label"></p>
Copy after login

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