I have URLs which always end on a number, for example:
String url = "localhost:8080/myproject/reader/add/1/";
String anotherurl = "localhost:8080/myproject/actor/take/154/";
I want to extract the number between the last two slashes ("/").
Does anyone know how I can do this?
You could split the string:
String[] items = url.split("/");
String number = items[items.length-1]; //last item before the last slash
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With