import re


def _split_regexp(restr):
    """Return a 2-tuple consisting of a compiled regular expression
    object and a boolean flag indicating if that object should be
    interpreted inversely."""
    if restr[0] == "!":
        return re.compile(restr[1:]), 1
    return re.compile(restr), 0