Please, assist with RegEx which reads String object and gets SRC of
all HTML IMG tags. This code does it but it returns "<img src='"
prefix in front of it if using (/<img[^>]+src=('|")([^'"]+)/ig).
Thanks.
JavaScript:
var strText = "ab cd efg hig klmnop <img src='file.jpg'> ot her"+
" e <IMG SRC='www.g.com/file2.jpg' BORDER=0>";
var separateBy = "\n";
var result = ""; // if no match, use this
var allMatches = strText.match(/<img[^>]+src=('|")([^'"]+)/ig);
if (allMatches) {
result = "";
for (var i = 0; i < allMatches.length; i++) {
if (i != 0) result += separateBy;
result += allMatches[i];
}
}
alert(result)
}
Paul Tomblin - 17 Jul 2007 17:55 GMT
In a previous article, vunet.us@gmail.com said:
>JavaScript:
Wrong newsgroup.

Signature
Paul Tomblin <ptomblin@xcski.com> http://blog.xcski.com/
Science is like sex: sometimes something useful comes out, but that's
not why we're doing it.
-- Richard Feynman
Daniel Pitts - 18 Jul 2007 21:01 GMT
On Jul 17, 8:28 am, vunet...@gmail.com wrote:
> Please, assist with RegEx which reads String object and gets SRC of
> all HTML IMG tags. This code does it but it returns "<img src='"
[quoted text clipped - 19 lines]
>
> }
This is a Java newsgroup, not a JavaScript newsgroup.