remove everything before the last occurrence of a character

You have the right idea just replace the brackets with parentheses.

var string = "/Roland/index.php";
var result = string.substring(string.lastIndexOf("https://stackoverflow.com/") + 1);

Here is an example in jsfiddle and here is an explanation of the .lastIndexOf() method on the Mozilla Developer Network.

Leave a Comment