def replace_data(original_string, off, old_len, string_to_insert):
    """
    Replace part of a string with a new string (lengths may be different).
    :param original_string: original string
    :param off: offset in original string to replace data at
    :param old_len: length of the original string
    :param string_to_insert: new string to replace substring with
    :return: a new string after substring replacement
    """
    data_to_insert_list = list(string_to_insert)
    original_data_list = list(original_string)
    new_data_list = original_data_list[:off] + data_to_insert_list + original_data_list[off + old_len:]
    return "".join(new_data_list)