code: public IAtomContainer processFormula(IAtomContainer parsedContent, String atomsEncoding) {
          logger.debug("Parsing atom data: ", atomsEncoding);
  
          Pattern pattern = Pattern.compile("([A-Z][a-z]?)(\\d+)?(.*)");
          String remainder = atomsEncoding;
          while (remainder.length() > 0) {
              logger.debug("Remaining: ", remainder);
              Matcher matcher = pattern.matcher(remainder);
              if (matcher.matches()) {
                  String symbol = matcher.group(1);
                  logger.debug("Atom symbol: ", symbol);
                  if (symbol.equals("H")) {
                      // don't add explicit hydrogens
                  } else {
                      String occurenceStr = matcher.group(2);
                      int occurence = 1;
                      if (occurenceStr != null) {
                          occurence = Integer.parseInt(occurenceStr);
                      }
                      logger.debug("  occurence: ", occurence);
                      for (int i = 1; i <= occurence; i++) {
                          parsedContent.addAtom(parsedContent.getBuilder().newInstance(IAtom.class, symbol));
                      }
                  }
                  remainder = matcher.group(3);
                  if (remainder == null) remainder = "";
                  logger.debug("  Remaining: ", remainder);
              } else {
                  logger.error("No match found!");
                  remainder = "";
              }
              logger.debug("NO atoms: ", parsedContent.getAtomCount());
          }
          return parsedContent;
      }
docs: Processes the content from the formula field of the INChI.
  Typical values look like C6H6, from INChI=1.12Beta/C6H6/c1-2-4-6-5-3-1/h1-6H.