I\'m trying to match all the images elements as strings,
This is my regex:
html.match(/
]+src=\"http([^\">]+)/g);
Th
As Mathletics mentioned in a comment, there are other more straightforward ways to retrieve the src attribute from your
tags such as retrieving a reference to the DOM node via id, name, class, etc. and then just using your reference to extract the information you need. If you need to do this for all of your
elements, you can do something like this:
var imageTags = document.getElementsByTagName("img"); // Returns array of
DOM nodes
var sources = [];
for (var i in imageTags) {
var src = imageTags[i].src;
sources.push(src);
}
However, if you have some restriction forcing you to use regex, then the other answers provided will work just fine.