import re


def get_device_number(device):
    """Extract device number.

    Ex: "D1000" → "1000"
        "X0x1A" → "0x1A
    """
    device_num = re.search(r"\d.*", device)
    if device_num is None:
        raise ValueError("Invalid device number, {}".format(device))
    else:
        device_num_str = device_num.group(0)
    return device_num_str