import re


def format_card(card_num):
    """
    Formats card numbers to remove any spaces, unnecessary characters, etc

    Input: Card number, integer or string
    Output: Correctly formatted card number, string
    """
    card_num = str(card_num)
    # Regex to remove any nondigit characters
    return re.sub(r"\D", "", card_num)