import re


def cut_part(
        text: str,
        split_pattern: re.Pattern,
        with_spliter: bool = True,
        with_offset: bool = False) -> list:
    """
    Cut text to parts by the given Regex Pattern.

    Parameters
    ----------
    text: raw text.
    split_pattern: how to split text.
    with_spliter: whether the parts contain spliters.
    with_offset: whether the parts contain offsets.

    Returns
    --------
    out: cutted parts.
    """
    spliters = split_pattern.findall(text)
    length = len(spliters)
    lst = []
    start = 0
    for i, part in enumerate(split_pattern.split(text)):
        if i < length:
            if with_spliter:
                part = part + spliters[i]
                len_spliter = 0
            else:
                len_spliter = len(spliters[i])
        else:
            len_spliter = 0
        end = start + len(part) + len_spliter
        if part:
            if with_offset:
                item = (part, start, end)
            else:
                item = part
            lst.append(item)
        start = end
    return lst