I have this url in javascript "/people/things/" I want a function that will only return "things" how do I do this?
I've tried ugly stuff. Like iterating but I get stuck when I have to figure out how to delete the rest of the string and its very slow asymptotically.
I keep getting "ILLEGAL". Super annoying.
$(function() {
var parse = function(str) {
var a = "";
if (str.length && str.length > 1) {
str = str.slice(0, str.length -1); //remove first
for (var i = str.length; i > 1; i--) {
if (str[i] !== '\\' ) {
a += str[i];
}
}
}
return a;
};
c = "\things\stuff\";
alert(parse(c)); //result should be "things"
});