从字符串中获取特定值

grab specifc value from a string

有谁知道如何从字符串中获取图像 URL?我可能会得到 2 URL's 或两个以上用逗号分隔,其中一些不是图像。

 var sample_str = "http://domain.com/test.html,http://another.domain.com/images/1234.jpg";

基本上我想做的是只获取图像 URL 并忽略其余部分。

 http://another.domain.com/images/1234.jpg

通过值使用拆分和 运行。沿着:

var s = "http://domain.com/test.html,http://another.domain.com/images/1234.jpg";
var ss = s.split(",");
for (var i=0; i<ss.length; i++) {
//for (var i in ss) {
    document.write(ss[i]);
    document.write("<br/>");
}