i have a url like: http://example.com:8080/files/username/oldpassword/12351.png
i need to replace oldpassword with: new password.
oldpassword is not fixed string, it's unknown string.
currently i use this code:
String url = "http://example.com:8080/files/username/oldpassword/12351.png";
String[] split = url.split("/");
String oldPass = split[5];
String newPass = "anyNewRandomPassword";
if( !oldPass.equals(newPass)) {
url = url.replace(oldPass, newPass);
}
i think it can be done using regex.
any help s much appreciated.