In your first snippet, you forgot to put the {e<=1}
in a string. In your final snippet, I think the problem is, that format
tries to deal with the {e<=1}
itself. So either you use concatenation:
print regex.search(test_1 + '{e<=1}', statement).group(0)
or you escape the literal braces, by doubling them:
print regex.search('{}{{e<=1}}'.format(test_1), statement).group(0)
This can then easily be extended to
print regex.search('{}{{e<={}}}'.format(test_1, num_of_errors), statement).group(0)