Here's an example html string:
PS: Notice how the string can have any random attributes in an image, some images can close with "/>", some with ">". It shouldn't matter. The regex should filter all the noise and capture all images src in an array.
The answers given in stackoverflow don't account for spaces inside the image tag and attributes between
<div>
<div>
<div>
<img title= "SOME TITLE" src="SOME IMAGE" alt="SOME ALT" />
<img alt="SOME ALT" title="SOME TITLE" src= "SOME IMAGE" >
</div>
<img src="SOME IMAGE">
</div>
<div>
<img alt ="SOME ALT" src= "SOME IMAGE" title="SOME TITLE">
</div>
<img src="SOME IMAGE" alt="SOME ALT" title="SOME TITLE" />
< img src ="SOME IMAGE" alt="SOME ALT" title="SOME TITLE" />
</div>
I'm looking for code like this:
var pictures = [],
m,
rx = /SOME REGEX/g;
while (m = rx.exec(str)) { //str being the html string of any sort
pictures.push(m[SOME INDEX]); //m[SOME INDEX] to match the value of src attribute
}