I have an image tag as below,
var img = '<img src="http://fmp-8.cit.nih.gov/hembase/search2images/chrX.jpg" alt="image x">';
I want to find the src of this img,i wrote the code as below,
var rex = /<img[^>]+src="?([^"\s]+)"?[^>]*\/>/g;
while (m = rex.exec(text)) {
imageUrls.push(m[1]);
}
But my imageUrls in empty even src element is there. Can any one please help me?
var m, imageUrls = [],
rex = /<img[^>]+src="?([^"\s]+)"?[^>]*\/>/g;
while (m = rex.exec(text)) {
imageUrls.push(m[1]);
}console.log(imageUrls+'lslsls')
for (var i = 0; i < imageUrls.length; i++) {
text = text.replace(/<img[^>]*>/, '<amp-img layout="responsive" class="ampimageheight" src="' + imageUrls[i] + '" width="200" height= "100"></amp-img>');
}