Reputation: 1552
I am getting index of a particular character in a string but not getting last index.I am using jquery function.
For example: "abch/" by index of method I am getting the index of '/',But for "aa/aaaee/" i want the index of last '/'.I have used lasytindex of but it is not working.
My code:
if (request.term.IndexOf("/") == (request.term.length - 1)) {
var term = request.term.slice(0, -1);
}
Upvotes: 1
Views: 234
Reputation: 82231
You can use .lastIndexOf()
:
request.term.lastIndexOf("/");
Upvotes: 1