import re


def edit_text_file(filepath: str, regex_search_string: str, replace_string: str):
    """
    This function is used to replace text inside a file.
    :param filepath: the path where the file is located.
    :param regex_search_string: string used in the regular expression to find what has to be replaced.
    :param replace_string: the string which will replace all matches found using regex_search_string.
    :return: None
    :raise RuntimeError: if regex_search_string doesn't find any match.
    """

    # open the file and read the content
    with open(filepath, "r") as f:
        text_file = f.read()

    # find all matches
    matches = re.finditer(regex_search_string, text_file)
    if matches is None:
        raise RuntimeError("No match has been found using the given regex_search_string!")

    # replace all matches with replace_string
    for match in matches:
        text_file = text_file.replace(match.group(0), replace_string)

    # overwrite the file
    with open(filepath, "w") as f:
        f.write(text_file)

    return None