求正则表达式完成这个需求,该如何解决
时间:2021-07-01 10:21:17
帮助过:25人阅读
求正则表达式完成这个需求

找到文章中这样的图片,替换成

如何写正则表达式,然后如何处理呢
------解决方案--------------------$html = <<

html;
$regImg = preg_match_all('/
\")
/', $html, $matches) ;
$newSrc = $matches[1][0].'!static"'." _src=\"".$matches[1][0]."!static\" tsrc=\"".$matches[1][0];
$html = str_replace($matches[1][0], $newSrc, $html);
var_dump($html);