var str = "/asdasf/asfaewf/agaegr/trer/rhh"; var index = str .lastIndexOf("\/"); str = str .substring(index + 1, str .length); alert(str );