import re


def get_postcode(address_string):
    """
    Takes an address and returns the postcode, or None if no postcode is found.
    """

    address_string = address_string.upper()
    pc_regex = "([A-PR-UWYZ]([1-9]([0-9]|[A-HJKSTUW])?|[A-HK-Y][1-9]([0-9]|[ABEHMNPRVWXY])?) *[0-9][ABD-HJLNP-UW-Z]{2}|GIR *0AA)"
    matches = re.search(pc_regex, address_string)

    if matches:
        return matches.group(1)
    else:
        return None