mongoDB中find查询使用Perl兼容的正则表达式perl中正则表达式简述:Http://www.chinaunix.net/old_jh/25/159388.html 示例:>&nb
perl中正则表达式简述:Http://www.chinaunix.net/old_jh/25/159388.html
示例:
> db.post.find()
{ "_id" : ObjectId("54a530c3ff0df3732bac1681"), "id" : 2, "name" : "joe", "age" : 30, "sex" : 1, "school" : "marry" }
{ "_id" : ObjectId("54a530c3ff0df3732bac1680"), "id" : 1, "name" : "joe", "age" : 30, "comments" : [ "test2", "test9", "test5" ], "sex" : 1, "school" : "marry" }
{ "_id" : ObjectId("54a9700e1b5afd45354fd086"), "id" : 3, "test3" : 3 }
{ "_id" : ObjectId("54a9701c1b5afd45354fd087"), "id" : 4, "test4" : 4 }
{ "_id" : ObjectId("54a970281b5afd45354fd088"), "id" : 5, "test5" : 5 }
{ "_id" : ObjectId("54a970351b5afd45354fd089"), "id" : 6, "test6" : 6 }
{ "_id" : ObjectId("54a970781b5afd45354fd08a"), "id" : 7, "test7" : 7 }
{ "_id" : ObjectId("54a970831b5afd45354fd08b"), "id" : 8, "test8" : 8 }
{ "_id" : ObjectId("54a970901b5afd45354fd08c"), "id" : 9, "test9" : 9 }
{ "_id" : ObjectId("54a9709c1b5afd45354fd08d"), "id" : 10, "test10" : 10 }
{ "_id" : ObjectId("54aa8a90652d8bdfa0566d34"), "id" : 11, "test10" : 11 }
> db.post.find({"school":/m/i})
{ "_id" : ObjectId("54a530c3ff0df3732bac1681"), "id" : 2, "name" : "joe", "age" : 30, "sex" : 1, "school" : "marry" }
{ "_id" : ObjectId("54a530c3ff0df3732bac1680"), "id" : 1, "name" : "joe", "age" : 30, "comments" : [ "test2", "test9", "test5" ], "sex" : 1, "school" : "marry" }
/模式/i , 表示系统接收//中指定的模式;
--结束END--
本文标题: 【MongoDB学习笔记16】MongoDB的查询:find中的正则表达式
本文链接: https://lsjlt.com/news/42947.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0