private static void validateName(String name) {
        Matcher digitMatcher;
        Matcher nameMatcher;
        Matcher whitespaceMatcher;

        boolean atStart = true;
        boolean arrayOk = true;
        boolean mapOk = true;
        for (int i = 0; i < name.length(); i++) {
            String s = name.substring(i, i + 1);
            digitMatcher = digitPattern.matcher(s);
            nameMatcher = namePattern.matcher(s);
            whitespaceMatcher = whitespacePattern.matcher(s);
            if (atStart) {
                if (digitMatcher.matches()) {
                    throw new IllegalArgumentException(name + " must start with a non-digit character");
                }
                if (!nameMatcher.matches()) {
                    throw new IllegalArgumentException(name + " contains unexpected character");
                }
                atStart = false;
            } else {
                if (nameMatcher.matches()) {
                    // do nothing
                } else if (s.equals(".")) {
                    arrayOk = true;
                    mapOk = true;
                    atStart = true;
                } else if (s.equals("[")) {
                    if (!arrayOk) {
                        throw new IllegalArgumentException(name + " Arrays cannot be multidimensional");
                    }
                    arrayOk = false;
                    if ((i > (name.length() - 2)) || name.charAt(i + 1) != ']') {
                        throw new IllegalArgumentException(name + " Expected ] to terminate array definition");
                    }
                    i++;
                } else if (s.equals("{")) {
                    if (!mapOk) {
                        throw new IllegalArgumentException(name + " Maps cannot be multidimensional");
                    }
                    mapOk = false;
                    if ((i > (name.length() - 2)) || name.charAt(i + 1) != '}') {
                        throw new IllegalArgumentException(name + " Expected } to terminate map definition");
                    }
                    i++;
                } else if (whitespaceMatcher.matches()) {
                    break;
                } else {
                    throw new IllegalArgumentException("'" + name + "' contains an unexpected character");
                }
            }
        }
    }
Special function that searches through s and returns the index
of the first occurrence of " that is not escaped.
configgen/src/main/java/com/yahoo/config/codegen/DefLine.java