How to get everything after last slash in a URL?

You don’t need fancy things, just see the string methods in the standard library and you can easily split your url between ‘filename’ part and the rest:

url.rsplit("https://stackoverflow.com/", 1)

So you can get the part you’re interested in simply with:

url.rsplit("https://stackoverflow.com/", 1)[-1]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)