remove compare re.compile to self.pattern test, replace with isinstance call