public static int countArgumentPlaceholders(final String messagePattern) {
    if (messagePattern == null) {
      return 0;
    }

    final int delim = messagePattern.indexOf(DELIM_START);

    if (delim == -1) {
      // special case, no placeholders at all.
      return 0;
    }
    int result = 0;
    boolean isEscaped = false;
    for (int i = 0; i < messagePattern.length(); i++) {
      final char curChar = messagePattern.charAt(i);
      if (curChar == ESCAPE_CHAR) {
        isEscaped = !isEscaped;
      } else if (curChar == DELIM_START) {
        if (!isEscaped && i < messagePattern.length() - 1
            && messagePattern.charAt(i + 1) == DELIM_STOP) {
          result++;
          i++;
        }
        isEscaped = false;
      } else {
        isEscaped = false;
      }
    }
    return result;
  }
Counts the number of unescaped placeholders in the given messagePattern.

@param messagePattern the message pattern to be analyzed.
@return the number of unescaped placeholders.
geode-logging/src/main/java/org/apache/geode/logging/internal/log4j/api/message/GemFireParameterizedMessage.java