import re


def serpent_xs_nucs_available(xsdata):
    """Finds the nuclides available to serpent for cross-section generation.

    Args:
        * xsdata (str): path to serpent *.xsdata file that will be used.

    Returns:
        * serpent_nucs (set): Set of nuclides serpent has available.
    """
    # Grabs the ZAID and metastable flag separately
    xsdata_pattern = "\s*[\dA-Za-z-]+\.\d{2}[a-z]\s+\d{4,6}\.\d{2}[a-z]  \d\s+(\d{4,6})  (\d)\s+.*"

    with open(xsdata, 'r') as f:
        raw_xsdata = f.read()

    serpent_nuc = set(int(''.join(m.groups())) for m in re.finditer(xsdata_pattern, raw_xsdata))
    return serpent_nuc