正则问题 将图片宽度替换为100%
宽度不定的图片
$str = '<p><br></p><img style="width: 513px;" src="<br />http://xxxx/uploads/details/142163431741415.jpg"><img style="width: 513px;" src="<br />http://xxxx/uploads/details/14216343172321.jpg"><p><br></p>';
$str = '<p><br></p><img style="width: 100%;" src="<br />http://xxxx/uploads/details/142163431741415.jpg"><img style="width: 100%;" src="<br />http://xxxx/uploads/details/14216343172321.jpg"><p><br></p>';
$str = '<p><br></p><img style="width: 513px;" src="<br />http://xxxx/uploads/details/142163431741415.jpg"><img style="width: 613px;" src="<br />http://xxxx/uploads/details/14216343172321.jpg"><p><br></p>';<br /><br />echo preg_replace('/(?<=style="width:).+?px;/i', '100%', $str);
echo preg_replace('/(?<=<img)(.+?)style="width\: .+?"/s', '$1style="width: 100%;"', $str);