如何指定一个正则表达式并忽略大小写:
regex = ".*" + filter + ".*";
config.gThingCollection.find({"name":{"$regex":regex}})
我希望过滤器不区分大小写,如何实现?
最佳答案
尝试改用 python 正则表达式对象。 Pymongo 会正确序列化它们:
import re
config.gThingCollection.find({"name": re.compile(regex, re.IGNORECASE)})
关于python mongodb正则表达式: ignore case,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4976278/