import re


def hex2rgb(hex_code: str) -> tuple:
    """
    Convert color given in hex code to RGB in ints. Result is returned inside 3-element tuple.

    :param hex_code:
    :return: tuple (R, G, B)
    """
    pattern = re.compile(r'^#?[a-fA-F0-9]{6}$')
    if not re.match(pattern, hex_code):
        raise ValueError('Hex code should have 6 characters')
    h = hex_code.lstrip('#')

    return tuple(int(h[i: i + 2], 16) for i in (0, 2, 4))