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;
    }
@Test
    public void testExpansions() {
        HashSet<String> expected1 = new HashSet<>(Arrays.asList(
            "foo1",
            "foo2",
            "foo3"
        ));
        assertEquals(expected1, StringExpander.expand("foo[1-3]"));

        HashSet<String> expected2 = new HashSet<>(Arrays.asList(
            "foo bar baz 0"
        ));
        assertEquals(expected2, StringExpander.expand("foo bar baz [0-0]"));

        HashSet<String> expected3 = new HashSet<>(Arrays.asList(
            "[[ wow50 ]]",
            "[[ wow51 ]]",
            "[[ wow52 ]]"
        ));
        assertEquals(expected3, StringExpander.expand("[[ wow[50-52] ]]"));

        HashSet<String> expected4 = new HashSet<>(Arrays.asList(
            "foo1bar",
            "foo2bar",
            "foo3bar"
        ));
        assertEquals(expected4, StringExpander.expand("foo[1-3]bar"));

        // should expand latest range first
        HashSet<String> expected5 = new HashSet<>(Arrays.asList(
            "start[1-3]middle1epilogue",
            "start[1-3]middle2epilogue",
            "start[1-3]middle3epilogue"
        ));
        assertEquals(expected5, StringExpander.expand("start[1-3]middle[1-3]epilogue"));
    }