You can split the string into a list and grab the last element in the list via a function.
function checkString(stringToCheck) {
var list1 = stringToCheck.split('/');
if (list1[list1.length - 1].length < 1) {
var item = list1[list1.length - 2]
} else {
var item = list1[list1.length - 1];
}
$('#results').append('Last Folder in '+stringToCheck+': <b>'+item+'</b><br>');
}
From there you can find the last actual element.
JSFiddle Example
While it may not be the most elegant answer, it seems to be the easiest to understand for someone that might not know regular expressions.
Updated JSFiddle to display the results.