public static String extractPasswordFromImageUrl(String imageUrl){
  Pattern r=Pattern.compile(IMAGEURL_PASSWORD_SPLIT_REGEX);
  Matcher m=r.matcher(imageUrl);
  String password=null;
  if (m.find() && m.groupCount() >= 2 && StringUtils.isNotBlank(m.group(2))) {
    password=m.group(2);
    Pattern hostpattern=Pattern.compile(IMAGEURL_HOST_REGEX);
    Matcher hostMatcher=hostpattern.matcher(password);
    if (hostMatcher.find()) {
      String preHostregex="^(.*?)\\@" + hostMatcher.group(1);
      Pattern pwdPattern=Pattern.compile(preHostregex);
      Matcher pwdMatcher=pwdPattern.matcher(password);
      if (pwdMatcher.find()) {
        password=pwdMatcher.group(1);
      }
    }
  }
  return password;
}

public static String extractPasswordFromImageUrl ( String imageUrl ) { Pattern r = Pattern . compile ( IMAGEURL_PASSWORD_SPLIT_REGEX ) ; Matcher m = r . matcher ( imageUrl ) ; String password = null ; if ( m . find ( ) && m . groupCount ( ) >= 2 && StringUtils . isNotBlank ( m . group ( 2 ) ) ) { password = m . group ( 2 ) ; Pattern hostpattern = Pattern . compile ( IMAGEURL_HOST_REGEX ) ; Matcher hostMatcher = hostpattern . matcher ( password ) ; if ( hostMatcher . find ( ) ) { String preHostregex = "^(.*?)\\@" + hostMatcher . group ( 1 ) ; Pattern pwdPattern = Pattern . compile ( preHostregex ) ; Matcher pwdMatcher = pwdPattern . matcher ( password ) ; if ( pwdMatcher . find ( ) ) { password = pwdMatcher . group ( 1 ) ; } } } return password ; }
extract password if present from the given imageurl string
