def is_exact(needle, haystack, start, end, matchnot):
    """Check exact occurrence of needle in haystack"""
    return (start >= 0 and end < len(haystack) and haystack[start:end] ==
        needle) ^ matchnot
