所以我想重新命名多个音轨
来自
10。黑洞太阳_Soundgarden
到
10。声音花园_黑洞太阳
我发现了这个:
var char2find = "_";
var index = name.lastIndexOf(char2find);
newName = name.substr(index+1) + char2find + name.substr(0,index);
但这会将乐队名称移到数字前面,如下所示:
声音花园_10。黑洞太阳
我尝试对其进行调整以满足我的需求,但效果不佳。有人可以让我知道我做错了什么吗?非常感谢任何帮助。
使用split方法拆分Name和sequence number
const name = "10. Black Hole Sun_Soundgarden" const char2find = "_"; const [i, n] = name.split(". ") const index = n.lastIndexOf(char2find); const newName = n.substr(index + 1) + char2find + n.substr(0, index); const result = i + ". " + newName console.log(result) // 10. Soundgarden_Black Hole Sun