87,991
社区成员
发帖
与我相关
我的任务
分享
var s = 'var str = http://10.2.20.87/file/upload';
alert(s.split(/\//)[2]);
var str = "http://10.2.20.87/file/upload";
alert(str.indexOf('/'));
alert(str.indexOf('/',str.indexOf('/')+1));
var s = "http://10.2.20.87/file/upload";
function getIndex(url) {
var temp = url.match(/[^\/]+(\/)+[^\/]+\//g);
return temp? Math.max(0, temp[0].length - 1) : -1;
}
alert(getIndex(s));
var s = 'http://10.2.20.87/file/upload';
alert(s.replace('/','a').indexOf('/'))