If you have a provided url, you can do it like this:
var url = 'http://www.odsavacky.cz/blog/wpcproduct/mikronebulizer/'; var urlsplit = url.split('/'); var urlEnd = urlsplit[urlsplit.length- (urlsplit[urlsplit.length-1] == '' ? 2 : 1)];
This will match either after the last slash, if there is any content there, otherwise it will match the part between the last and the last slash.
source share