import re


def get_substr(st, de1, de2, strip=True):
    """
    Return the first occurrence of a substring between delimiters delim1 and
    delim2 from a string. If either delimiter isn't given, return substring
    from start or until the end of string. If strip is set true, strip the
    result. If nothing is found, return None.
    :param st: String from which we search for substr
    :param de1: First delimiter (string)
    :param de2: Second delimiter (string)
    :param strip: Toggle result stripping (boolean)
    :return: String or None
    """
    if not st or st == '' or not isinstance(strip, bool):
        raise ValueError

    res = re.search(
        (de1 if de1 else '') + '(.*)' + (de2 if de2 else ''), st)

    if not res:
        return None

    ret = str(res.group(1))

    if strip:
        ret = ret.strip()

    return ret