我的网址总是以数字结尾,例如:
String url = "localhost:8080/myproject/reader/add/1/";
String anotherurl = "localhost:8080/myproject/actor/take/154/";
Run Code Online (Sandbox Code Playgroud)
我想提取最后两个斜杠("/")之间的数字.
有谁知道我怎么做到这一点?
你可以拆分字符串:
String[] items = url.split("/");
String number = items[items.length-1]; //last item before the last slash
Run Code Online (Sandbox Code Playgroud)