import re


def _sanitize_code(code):
    """Return code with non-digit characters removed.

    Args:
        code: String containing digit and other characters.
    Returns:
        String containing only digit characters.
    """
    if not isinstance(code, str):
        raise TypeError('code must be a string.')
    return re.sub('[^\d]', '', code)