def get_code_num_rgb(s: str) -> Optional[Tuple[int, int, int]]:
    """ Get rgb code numbers from an RGB escape code.
        Raises InvalidRgbEscapeCode if an invalid number is found.
    """
    parts = s.split(';')
    if len(parts) != 5:
        raise InvalidRgbEscapeCode(s, reason='Count is off.')
    rgbparts = parts[-3:]
    if not rgbparts[2].endswith('m'):
        raise InvalidRgbEscapeCode(s, reason='Missing \'m\' on the end.')

    rgbparts[2] = rgbparts[2].rstrip('m')
    try:
        r, g, b = [int(x) for x in rgbparts]
    except ValueError as ex:
        raise InvalidRgbEscapeCode(s) from ex

    if not all(in_range(x, 0, 255) for x in (r, g, b)):
        raise InvalidRgbEscapeCode(s, reason='Not in range 0-255.')
    return r, g, b
Get rgb code numbers from an RGB escape code.
        Raises InvalidRgbEscapeCode if an invalid number is found.