import re


def match_kernel_id(fpath):
    """Get kernel id from file path: 'kernel-24536.json' -> '24536'.

    Parameters
    ----------
    fpath : :obj:`pathlib.Path` or str
        Filename (or full path) from which to find kernel id.

    Returns
    -------
    str
        Kernel id as a string.
    """
    m_kernel = re.search(r'kernel-(.+)\.json', str(fpath))
    return m_kernel[1] if m_kernel else None