'Remove all rules matching regex.'

def remove_rules_regex(self, regex):

    if isinstance(regex, six.string_types):
        regex = re.compile(regex)
    num_rules = len(self.rules)
    self.rules = [r for r in self.rules if (not regex.match(str(r)))]
    removed = (num_rules - len(self.rules))
    if (removed > 0):
        self.dirty = True
    return removed
