正则获取html标签字符串中图片地址

html标签字符串:

var htmlStr = "<div class='testClass'><img=http://www.chinanews.com/part/home2013/451/U610P4T451D5F17247DT20190218112223.jpg></div>";

需求:使用正则获取img图片地址

1、使用正则后向引用

提示  * 为invalid quantifier,需要添加上 代表任意字符的

var htmlStr = "<div class='testClass'><img=http://www.chinanews.com/part/home2013/451/U610P4T451D5F17247DT20190218112223.jpg></div>";
htmlStr.match(/(?<=<div .*><img=).*(?=></div>)/g);

成功获取图片地址

原文地址:https://www.cnblogs.com/loveamyforever/p/10395742.html