SOURCE

var value="    https://coupon.m.jd.com/coupons/show.action?linkKey=AAROH_xIpeffAs_-naABEFoeRj5ih0bA23YxmtwfSSDifkzn   IcUlplZK0YZUCielDDaVo4lcBalYocgB4Zrb3QxWJZBqFAh\r\nhttp://coupon.m.jd.com/coupons/show.action?key=5cabb9bd9ed1449cb8675ee66b0f2bd8&roleId=55223240&to=item.jd.com/10033460458973.html"
var value=value.replace(/\ +/g,"").replace(/[\r\n]/g,"")
var lgsy=[];
var data=[];
var str = value
var index = str.indexOf('http'); // 字符出现的位置
var num = 0; // 这个字符出现的次数
while(index !== -1) {
    lgsy.push(index);
    console.log(index); // 打印字符串出现的位置
    num++; // 每出现一次 次数加一
    index = str.indexOf('http',index + 1); // 从字符串出现的位置的下一位置开始继续查找
}
lgsy.push(value.length);
debugger
for(i=1;i<lgsy.length;i++){
    if(lgsy.length==1){
        data.push(lgsy[i])
    }
    else{
         data.push(value.substr(lgsy[i-1],lgsy[i]))
    }
}
console.log('http一共出现了' + num + '次');
console.log(JSON.stringify(data))
console.log(value.substr(146,276))
debugger
console 命令行工具 X clear

                    
>
console