Home > Backend Development > PHP Tutorial > PHP regular replacement problem

PHP regular replacement problem

WBOY
Release: 2016-09-27 14:04:39
Original
920 people have browsed it

I am a regular comparison expert. Now there is a problem of regular replacement that I have been unable to solve. The demand is as follows:

tags in some content

<code><p style="dsfdsf">(这里有任意内容和标签)<img class="sdfdsf" src="tupian.jpg">( 这里也有任意内容和标签)</p>
</code>
Copy after login

Then replace the item with this:

<code><p style="dsfdsf">(这里有任意内容和标签)( 这里也有任意内容和标签)</p><figure><img src="tupian.jpg" /></figure>
</code>
Copy after login

To put it simply, img is wrapped with figure and then extracted and placed behind P. How to write it using preg_replace?

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