public static HashSet<String> expand(String val) {
        HashSet<String> set = new HashSet<>();
        Matcher matcher = NUMERIC_RANGE_PATTERN.matcher(val);
        if (!matcher.matches()) {
            set.add(val);
            return set;
        }
        String prequel = matcher.group(1);
        String rangeStart = matcher.group(2);
        String rangeEnd = matcher.group(3);
        String epilog = matcher.group(4);
        int rangeStartInt = Integer.parseInt(rangeStart);
        int rangeEndInt = Integer.parseInt(rangeEnd);
        if (rangeEndInt < rangeStartInt) {
            throw new RuntimeException("Invalid range: start " + rangeStartInt +
                    " is higher than end " + rangeEndInt);
        }
        for (int i = rangeStartInt; i <= rangeEndInt; i++) {
            set.add(String.format("%s%d%s", prequel, i, epilog));
        }
        return set;
    }
Utilities for expanding strings that have range expressions in them.

For example, 'foo[1-3]' would be expaneded to foo1, foo2, foo3.
Strings that have no range expressions will not be expanded.
trogdor/src/main/java/org/apache/kafka/trogdor/common/StringExpander.java