Php regular expression to delete the img Tag original method example, imgfont
This example describes how to delete the img Tag using php regular expressions. We will share this with you for your reference. The details are as follows:
I. Problems
The img label in the body needs to be deleted during regular expression capturing, for example:
<Div> welcome to the house of gangs </div>
It is required to be deleted and changed:
<Div> welcome to the customer's home </div>
Ii. solution:
$ Str = '<div> welcome to the customer's house </div> '; $ str = preg_replace ('/<\ s * img \ s + [^>] *? Src \ s * = \ s * (\ '| \")(.*?) \ 1 [^>] *? \/? \ S *>/I ', '', $ str); echo $ str;
Running result:
<Div> welcome to the customer's home </div>
PS: here we will provide two very convenient Regular Expression tools for your reference:
JavaScript Regular Expression online testing tool:
Http://tools.jb51.net/regex/javascript
Regular Expression generation tool:
Http://tools.jb51.net/regex/create_reg