I have string that looks like a url. For example:
.com/ - finds nothing
.com - finds nothing
/me - finds nothing
/me/ - finds nothing
/me/500/hello - finds nothing
/me/12/test/550 - I need find 550
/test/1500 - I need find 1500
/test/1500/ - I need find 1500
I need to extract always last digits, right now I do it this way
int index = url.lastIndexOf('/');
String found = url.substring(index + 1, url.length());
if(Pattern.matches("\\d+", found)) {
// If found digits at the end doSometihng
}
However I do not like this solution, and it does not work if I have slash at the end. What would be nice solution to catch last digits?