import re


def get_anchor_format(a):
    """Extract the resource file-type format from the anchor"""
    # (. or format=) then (file_extension) then (? or $)
    # e.g. "...format=txt" or "...download.mp4?..."
    file_format = re.search("(?:\.|format=)(\w+)(?:\?.*)?$", a)
    return file_format.group(1) if file_format else None