[Edited - Sorry Bart] I\'ve looked at other answers but struggling to match this. I want to wrap an image tag where the src is the second attribute (after title) with a specific
Similar questions have been answered several times and the answer is always the same: do not use regular expressions to tamper with HTML. In PHP, you can use XPath and the SimpleXml or DOMParser extensions to solve this problem.
Sorry for posting so many links to my own answers but the answers themselves and the questions they are answering contain a lot of information on the subject.