import re


def case_mismatch(vm_type, param):
    """Return True if vm_type matches a portion of param in a case
    insensitive search, but does not equal that portion;
    return False otherwise.
    The "portions" of param are delimited by "_".
    """
    re_portion = re.compile(
        "(^(%(x)s)_)|(_(%(x)s)_)|(_(%(x)s)$)" % dict(x=vm_type), re.IGNORECASE
    )
    found = re_portion.search(param)
    if found:
        param_vm_type = [x for x in found.groups()[1::2] if x][0]
        return param_vm_type != vm_type
    else:
        return False