I need to splice the last part of a string until we reach the first / character backwards. Which means if I have the following:
str = "Hello/World/Peace";
I would only like to take:
str = "Hello/World";
Where /Peace is removed.
The string could be longer: a/b/c/d/e/f so the result would always be by removing the last slash with what comes next => a/b/c/d/e.
I've checked this post, but it only works if there is only one slash:
str = "hello/world/wide/peace";
new_str = str.substring(str.indexOf("/")+1);
And the result is by splicing at the beginning not the end of it:
new_str = "world/wide/peace";
The desired output should be:
new_str = "hello/world/wide"
Here is a fiddle.