【笔记】JavaScript字符串查询截取替换
原文
代码
var str = "视频地址$https://iqiyi.com/index.m3u8$$$DVD国语中字$https://iqiyi.com/share/395db788289ee286662bbcabe78d99da";
console.log(getPlayUrl(str));
function getPlayUrl(str) {
var one = str.indexOf('$') + 1;//获取条件一首次出现位置
var two = str.indexOf('.m3u8');//获取条件二首次出现位置
var three = str.substr(one, two);//获取需要的字符串
console.log(three);
return three.replace(/\$/g, "");//替换无用掉残留字符串
}