$item->description = preg_replace("/\<center\>\<a href=\"(.*)\"\>\<img alt=\"\" src=\"(.*)\" \/\>\<\/a\>\<\/center\>/", "$2", $item->description);
但我需要将结果$2
放入字符串$item->image
怎么做?
答案 0 :(得分:1)
尝试:
$item->image = preg_replace("/.*\<center\>\<a href=\"(.*)\"\>\<img alt=\"\" src=\"(.*)\" \/\>\<\/a\>\<\/center\>.*/", "$2", str_replace("\n", '', $item->description));
如何使用正则表达式来解析html而不是DOM
而不是