def trim_string(s1: str, s2: str) -> str:
    """
    Removes any preceding or trailing instances of s2 from s1
    :param s1: the string from which preceding or trailing instances of s2 will be removed
    :param s2: the string that will be removed from the start and end of s1
    :return: s1 without any instances of s2 at either the start or end
    """
    if s2: # loops won't terminate if s2 is empty
        while s1.startswith(s2):
            s1 = s1.lstrip(s2)

        while s1.endswith(s2):
            s1 = s1.rstrip(s2)

    return s1