When passing an empty string to a regular expression object, the search result is a match object, not None. Should it be None, since there is nothing suitable?
import re
m = re.search("", "some text")
if m is None:
print "Returned None"
else:
print "Return a match"
By the way, the use of special characters ^and $gives the same result.
source
share