def replace_from_to(text, start_position, end_position, new_text):
    """ Replaces the substring within the given range against another text."""
    return "{}{}{}".format(text[:start_position], new_text, text[end_position:])