code: private static String parseStandardRegionName(final String fragment) {
  
          Matcher matcher = S3_ENDPOINT_PATTERN.matcher(fragment);
          if (matcher.matches()) {
              // host was 'bucket.s3-[region].amazonaws.com'.
              return matcher.group(1);
          }
  
          matcher = STANDARD_CLOUDSEARCH_ENDPOINT_PATTERN.matcher(fragment);
          if (matcher.matches()) {
              // host was 'domain.[region].cloudsearch.amazonaws.com'.
              return matcher.group(1);
          }
  
          int index = fragment.lastIndexOf('.');
          if (index == -1) {
              // host was 'service.amazonaws.com', guess us-east-1
              // for lack of a better option.
              return "us-east-1";
          }
  
          // host was 'service.[region].amazonaws.com'.
          String region = fragment.substring(index + 1);
  
          // Special case for iam.us-gov.amazonaws.com, which is actually
          // us-gov-west-1.
          if ("us-gov".equals(region)) {
              region = "us-gov-west-1";
          }
  
          return region;
      }
docs: Parses the region name from a standard (*.amazonaws.com) endpoint.
  
  @param fragment  the portion of the endpoint excluding
  &quot;.amazonaws.com&quot;
  @return          the parsed region name (or &quot;us-east-1&quot; as a
  best guess if we can't tell for sure)