code: public static String extractHostname(final String host) {
          String extracted = host;
          if (containsUserName(host)) {
              extracted = host.substring(host.indexOf("@") + 1, host.length());
          }
  
          if (containsPort(extracted)) {
              extracted = host.substring(0, host.indexOf(":"));
          }
  
          return extracted;
      }
docs: Extract hostname from a string of the pattern "username@hostname:port"
  
  @param host the hostname
  
  @return the extracted hostname, or the original string if the pattern is not matched