import re


def extract_year(string: str) -> int:
    """
    Extracts a four-digit valid year (1900-2099) from a string. If there
    are multiple four-digit valid years on the string, the first
    occurrence is returned.

    Parameters
    ----------
    string
        String to extract the year from.

    Returns
    -------
    int
        Four-digit integer representing the year.

    """
    expr = r"(?:19|20)\d{2}"
    matches = re.findall(expr, string)
    if matches:
        year = matches[0]
    else:
        raise Exception("The string does not have any valid year.")

    return int(year)