import re


def year_grabber(year_str: str):
    """
    From a string containing a year, possibly more than one, pull out the first.

    >>> year_grabber("1948194819491949195019501951")
    '1948'

    >>> year_grabber("abs1987")
    '1987'

    >>> year_grabber("1987a")
    '1987'

    >>> year_grabber("<y>1916&#8211;1917[1915&#8211;1917]</y>")
    '1916'

    """
    m = re.search(r"(?P<theyear>[12][0-9]{3,3})(.*)?", year_str)
    if m is not None:
        ret_val = m.group("theyear")
    else:
        ret_val = None

    return ret_val