def split(text):
    """Split a text, taking escape characters into account."""
    # See https://stackoverflow.com/a/21882672
    escape = '\\'
    ret = []
    current = []
    itr = iter(text)
    for ch in itr:
        if ch == escape:
            try:
                # skip the next character; it has been escaped!
                current.append(next(itr))
            except StopIteration:
                current.append(escape)
        elif ch == ';' or ch == ',':
            # split! (add current to the list and reset it)
            ret.append(''.join(current))
            current = []
        else:
            current.append(ch)
    if len(current) > 0:
        ret.append(''.join(current))
    return ret