from typing import Union
from typing import List
from typing import Tuple
import re


def split_delimiters(text: str, delimiters: Union[List[str], Tuple[str]]) -> List[tuple]:
    """
    Splits the text with delimiters and returns the list of tuples in which
    first entry is the splitted text and the second is the corresponding delimiter
    used. If there is text after last occurence of a delimiter, empty string will
    be used for last delimiter (second entry of last entry of the list).

    Parameters
    ----------
    text : str
        Input string to separate.
    delimiters : list or tuple 
        Delimiters that will be used to split the text.
    """

    if not text:
        return [('', delimiters[0])]

    pattern = '|'.join(map(re.escape, delimiters))

    # it returns the list in which the every second entry is the original delimiter used
    sp = re.split(f'({pattern})', text)

    entries = sp[::2]
    delimiters = sp[1::2]

    if len(delimiters) < len(entries):
        delimiters.append('')  # append '' as a delimiter if text did not end with delimiter

    return list(zip(entries, delimiters))