import re


def class_code_parser(class_code: str, pattern: str) -> str:
    """A default class code to subject code parser.

    Assumes that class codes contain their corresponding subject code.
    
    Args:
        class_code: The class code.
        pattern: A regex pattern that matches subject codes to a named group
            called 'code'.

    Returns:
        The subject code string.
    """
    m = re.search(pattern, class_code)
    if m:
        subject_code = m.group('code')
        return subject_code
    else:
        print(class_code + " class code not found")
        return ""