获取指定字符串中的图片地址,逗号分隔

/**
 * 获取字符串中的图片
 */
function getContentImg(str)
{
    var r, re, img_str = '';
    re = /<[img|href][^>]*src\s*=\s*('|")?([^'">]*)\1([^>])*>/ig;
    while ((r = re.exec(str)) != null) {
        img_str = img_str + r[2] + ',';
    }
    img_str = img_str == '' ? '' : img_str.substring(0, img_str.length-1);
    return img_str;
}

猜你喜欢

转载自blog.csdn.net/l5751311/article/details/8729953
今日推荐