public static Set<String> expandShorthand(String s) {
        Set<String> results = new HashSet<>();
        results.add(s);

        Set<String> workSet = new HashSet<>();
        while (true) {

            boolean work = false;
            for (String string : results) {
                Set<String> expanded = matchGroup(string);
                if (expanded != null) {
                    work = true;
                    workSet.addAll(expanded);
                } else {
                    workSet.add(string);
                }
            }

            if (work) {
                // set results := workSet, and init an empty workSet for the next iteration
                // (we actually sneakily reuse the existing results HashSet to avoid having to create a new one)
                Set<String> temp = results;
                results = workSet;
                workSet = temp;
                workSet.clear();
                continue;
            }

            break;
        }

        // remove self
        results.remove(s);

        return results;
    }
Parses and expands the shorthand format.

@param s the string to expand
@return the expanded result
common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java