RegEx – Get All Characters After Last Slash in URL

Don’t write a regex! This is trivial to do with string functions instead:

var final = id.substr(id.lastIndexOf("https://stackoverflow.com/") + 1);

It’s even easier if you know that the final part will always be 16 characters:

var final = id.substr(-16);

Leave a Comment