code: public static int findSectionClosingPosition(ByteBuf buf, int startOffset, char openingChar, char closingChar) {
          int from = buf.readerIndex() + startOffset;
          int length = buf.writerIndex() - from;
          if (length < 0) {
              throw new IllegalArgumentException("startOffset must not go beyond the readable byte length of the buffer");
          }
  
          return buf.forEachByte(from, length,
                  new ClosingPositionBufProcessor(openingChar, closingChar, true));
      }
docs: Finds the position of the correct closing character, taking into account the fact that before the correct one,
  other sub section with same opening and closing characters can be encountered.
  
  This implementation starts for the current {@link ByteBuf#readerIndex() readerIndex} + startOffset.
  
  @param buf the {@link ByteBuf} where to search for the end of a section enclosed in openingChar and closingChar.
  @param startOffset the offset at which to start reading (from buffer's readerIndex).
  @param openingChar the section opening char, used to detect a sub-section.
  @param closingChar the section closing char, used to detect the end of a sub-section / this section.
  @return the section closing position or -1 if not found.