showing results for - "string split last slash in js get previous results"
Sara
04 Mar 2019
1var str = "var1/var2/var3";
2
3var rest = str.substring(0, str.lastIndexOf("/") + 1);
4var last = str.substring(str.lastIndexOf("/") + 1, str.length);
5console.log(rest);
6console.log(last);