class MyTest:
a = re.compile('abc')
def testthis(self, fname):
print fname
if self.a.match(fname):
return 'yes'
else:
return 'no'
If I pass 'testabc' to testthis() then it prints no. If I change the regex to .*abc then it prints yes. What’s going on? Is it trying to match against the whole string?
From the docs (emphasis mine):
Perhaps you wanted
.search()instead.