public RegexResult selectGroup(String text) {
        Matcher matcher = regex.matcher(text);
        if (matcher.find()) {
            String[] groups = new String[matcher.groupCount() + 1];
            for (int i = 0; i < groups.length; i++) {
                groups[i] = matcher.group(i);
            }
            return new RegexResult(groups);
        }
        return RegexResult.EMPTY_RESULT;
    }
Create a RegexSelector. When there is no capture group, the value is set to 0 else set to 1.
@param regexStr the regular expression.
webmagic-core/src/main/java/us/codecraft/webmagic/selector/RegexSelector.java