code: public static Map<String, Properties> subProperties(Properties prop, String regex) {
      Map<String, Properties> subProperties = new HashMap<>();
      Pattern pattern = Pattern.compile(regex);
  
      for (Map.Entry<Object, Object> entry : prop.entrySet()) {
        Matcher m = pattern.matcher(entry.getKey().toString());
        if (m.find()) {
          String prefix = m.group(1);
          String suffix = m.group(2);
          if (!subProperties.containsKey(prefix)) {
            subProperties.put(prefix, new Properties());
          }
          subProperties.get(prefix).put(suffix, entry.getValue());
        }
      }
      return subProperties;
    }
docs: Uses regex to parse every original property key to a prefix and a suffix. Creates sub
  properties that are grouped by the prefix.
  
  @param prop the original properties
  @param regex prefix and suffix pattern
  @return a {@code Map} from the prefix to its properties