def re_split(regex, string, maxsplit):
    """Same as regex.split(string, maxsplit), but does not include the text in capturing groups.

    https://docs.python.org/3/library/re.html#re.split
    """
    if regex.match(''):
        raise ValueError('Delimiter matching empty string not supported')
    assert maxsplit > 0
    parts = []
    cur = 0
    for match in regex.finditer(string):
        start, end = match.span()
        assert start < end
        parts.append(string[cur:start])
        cur = end
        if len(parts) >= maxsplit:
            break
    assert cur <= len(string)
    parts.append(string[cur:])
    return parts
