import re


def get_age_sex(participant, fields=["31", "21022"]) -> list:
    """Create a list of age and sex field names

    Parameters
    ----------
    participant : UKB Spark df
        participant df
    fields : list, optional
        list of age and sex fields. Defaults are necessary for PHESANT, by default ["31", "21022"]

    Returns
    -------
    list
        age sex fields
    """
    age_sex = "|".join(fields)
    age_sex_fields = list(
        participant.find_fields(lambda f: bool(re.match(f"^p({age_sex})$", f.name)))
    )

    return [f.name for f in age_sex_fields]