presto-main/src/main/java/io/prestosql/operator/scalar/JoniRegexpFunctions.java/JoniRegexpFunctions/validateGroup
class JoniRegexpFunctions:    private static void validateGroup(long group, Region region)
    {
        if (group < 0) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, "Group cannot be negative");
        }
        if (group > region.numRegs - 1) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("Pattern has %d groups. Cannot access group %d", region.numRegs - 1, group));
        }
    }