pattern = re.compile(
    """
 ^( [0-9a-fA-F]{2} (?: \\s [0-9a-fA-F]{2} ){44}
                (?:(?: \\s [0-9a-fA-F]{2} ){3} )? )$ 
"""
    , re.VERBOSE)
Regular Expression for a pattern of 45 hex numbers OR 48 hex numbers - Python