PHP regular replacement picture matching address

Internet can find a lot of examples of matching image src regular expressions and replace, are natural and eggs, not solve the problem immediately.

Src just have to find where that period to replace the line.

To a piece of content:


$content = '<img src="http://www.domainname.com/600_0_100_1/1439035192.4102/1e45426fe3d5410eedd45a82d9a0aead.jpg" rel="12375880" alt=""/>';

Regular globs:
preg_replace ( "/ (<IMG * the src = \.?") (*) (\.? "*.?>) / IS", "\ $ {. 1} asdf \ $ {. 3}", $ content);

$ Content as long as the entire contents of a <img> tag on it, the src the contents of a single ring up, the content before and after all the whole comprising up $ {1} and $ {3} is a longitudinal content src will src want to replace the line.

----------------
Disclaimer: This article is the original article CSDN bloggers "NaivenJer", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement. .
Original link: https: //blog.csdn.net/the3z/article/details/47832857

Guess you like

Origin www.cnblogs.com/shixiuxian/p/12369976.html