js截取url字符串中某个词后面的内容

it2026-06-11  7

var url = 'http://xxx.xxx.xx.xx:8080/group1/123/00/03/123123123123.jpg' if (url.indexOf('8080') !== -1) { const requestUrl1 = url.substr(url.lastIndexOf('8080') + "8080".length + 1) console.log(requestUrl1) } const url = 'http://xxx.xxx.xx.xx:8080/group1/123/0220/03/123123123.jpg' console.log(url.split('/')) const arr = [] url.split('/').forEach((item,index)=>{ console.log(index) if(index!==0&&index!==1&&index!==2){ arr.push(item) } }) console.log(arr.join('/'))
最新回复(0)