code: private static int extractOptions(String pattern, int i, List options) {
      while ((i < pattern.length()) && (pattern.charAt(i) == '{')) {
        int end = pattern.indexOf('}', i);
  
        if (end == -1) {
          break;
        }
  
        String r = pattern.substring(i + 1, end);
        options.add(r);
        i = end + 1;
      }
  
      return i;
    }
docs: Extract options.
  @param pattern conversion pattern.
  @param i start of options.
  @param options array to receive extracted options
  @return position in pattern after options.