function getFileName(str){ var reg = /[^\\\/]*[\\\/]+/g; //xxx\或者是xxx/ str = str.replace(reg,''); return str; } var str2 = 'user/550bbc9e0ad08fac0b39c147/3706934783.mp3'; getFileName(str2)