How can I specify a REGEX and ignore the case:
regex = ".*" + filter + ".*";
config.gThingCollection.find({"name":{"$regex":regex}})
I want the filter to be case-insensitive, how to achieve that?
Try using the python regex objects instead. Pymongo will serialize them properly:
import re
config.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"}})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With