public static IntRange from(String s) {
        try {
            s = s.trim();
            if (s.startsWith("[") && s.endsWith("]")) {
                String innards = s.substring(1, s.length() - 1).trim();
                if (innards.isEmpty()) return empty();
                String[] numbers = (" " + innards + " ").split(","); // pad to make sure we get 2 elements
                if (numbers.length != 2) throw new IllegalArgumentException("Expected two numbers");
                return new IntRange(parseOptionalInt(numbers[0]), parseOptionalInt(numbers[1]));
            } else {
                var fromTo = parseOptionalInt(s);
                return new IntRange(fromTo, fromTo);
            }
        }
        catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Expected a number or range on the form [min, max], but got '" + s + "'", e);
        }
    }
Parses a value ("value"), value range ("[min-value?, max-value?]"), or empty.
config-provisioning/src/main/java/com/yahoo/config/provision/IntRange.java