import re


def infer_cid_from_uri(uri):
    """
    Given a URI, this function returns the CID.
    Returns None if the CID is not found.

    :param uri
    :type uri: str
    :return: cid
    :rtype: str | None
    """
    cid_pattern = r"Qm[a-zA-Z0-9-_]+"
    matches = re.search(cid_pattern, uri)
    if matches:
        return matches.group(0)
    return None