regex to wrap img tag with href containg the src

后端 未结 3 1232
别跟我提以往
别跟我提以往 2021-01-27 12:38

[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

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-27 13:04

    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.

提交回复
热议问题