import re


def extract_jobs_flags(mflags):
    """Extracts make job flags from a list of other make flags, i.e. -j8 -l8

    :param mflags: string of space separated make arguments
    :type mflags: str
    :returns: list of make jobs flags
    :rtype: list
    """
    if not mflags:
        return []

    # Each line matches a flag type, i.e. -j, -l, --jobs, --load-average
    # (?:^|\s) and (?=$|\s) make sure that the flag is surrounded by whitespace
    # (?:...) is just a group that will not be captured, this is necessary because the whole flag should be captured
    # The upper two expressions are simple, they just match the flag, optional whitespace and an optional number
    # The bottom two expressions are more complicated because the long flag may be # followed by '=' and a number,
    # whitespace and a number or nothing
    regex = r'(?:^|\s)(-j\s*\d*)(?=$|\s)|' + \
            r'(?:^|\s)(-l\s*\d*\.?\d*)(?=$|\s)|' + \
            r'(?:^|\s)(--jobs(?:(?:=|\s+)\d+)?)(?=$|\s)|' + \
            r'(?:^|\s)(--load-average(?:(?:=|\s+)\d*\.?\d+)?)(?=$|\s)'

    filtered_flags = []
    for match in re.findall(regex, mflags):
        filtered_flags.extend([m.strip() for m in match if m])

    return filtered_flags or None