>>> import re >>> s = re.search("/^[^\t]*\t[^\t]*\t[^\t]*$/", "\t\t") >>> s.group() Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'group'