Mongodb 在集合中搜索特殊字符 (\)
Mongodb search special character (\) in a collection
如何在 mongodb 中搜索以“\”开头的字符串。请帮忙
db.txt.insert({"name": "\paul"})
db.txt.insert({"name": "Oracle"})
db.txt.insert({"name": "\Testing program"})
需要输出:
\paul
\testing program
您需要使用 $regex
运算符。
db.txt.find({ "name": { "$regex": /^\/ }})
如何在 mongodb 中搜索以“\”开头的字符串。请帮忙
db.txt.insert({"name": "\paul"})
db.txt.insert({"name": "Oracle"})
db.txt.insert({"name": "\Testing program"})
需要输出:
\paul
\testing program
您需要使用 $regex
运算符。
db.txt.find({ "name": { "$regex": /^\/ }})