Like this:
var string = "/anything-here-this-needs-to-be-replaced123/but-keep-this";
string = string.substring(string.indexOf('/', 1));
You can view a demo here to play with, the .indexOf()
method takes an optional second argument, saying where to start the search, just use that with .substring()
here.
If you want to remove all leading slashes (unclear from the example), change it up a bit to .lastIndexOf()
without a start argument, like this:
var string = "/anything-here-this-needs-to-be-replaced123/but-keep-this";
string = string.substring(string.lastIndexOf('/'));
You can play with that here, the effect is the same for the example, but would be different in the case of more slashes.