Try using the python regex objects instead. Pymongo will serialize them properly:
import reconfig.gThingCollection.find({"name": re.compile(regex, re.IGNORECASE)})
You can use MongoDB regex options in your query.
config.gThingCollection.find({"name":{"$regex":regex, "$options": "-i"}})
res = posts.find({"geography": {"$regex": 'europe', "$options": 'i'}})# if you need use $notimport reres = posts.find( {"geography": {"$not": re.compile('europe'), "$options": 'i'}})