gpt4 book ai didi

node.js - Mongoose 不返回正则表达式子字符串

转载 作者:太空宇宙 更新时间:2023-11-04 00:27:55 24 4
gpt4 key购买 nike

Reference.find(
{$and: [
{'url': url},
{"text" : {$regex : text, '$options' : 'i'}}
]})

每当我用“Hello World”测试 text 时,我都会得到完全包含该文本的文档。但是,如果我执行“Hello Worl”,即使使用相同的 url,我也不会得到任何返回。我已经尝试了许多 ReGex 的实现,但到目前为止还没有成功。如果重要的话,我正在使用 Mongo 3.2.11。

最佳答案

尝试使用以下字符串'.*content.*'或正则表达式格式/.*content.*/,这是广泛支持的正则表达式格式。

另请参阅Checking if a field contains a string

关于node.js - Mongoose 不返回正则表达式子字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42100398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com