【MongoDB學習筆記16】MongoDB的查詢:find中的Regex

來源:互聯網
上載者:User

標籤:mongodb   Regex   perl   

MongoDB中find查詢使用Perl相容的Regex

perl中Regex簡述: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  , 表示系統接收//中指定的模式;



【MongoDB學習筆記16】MongoDB的查詢:find中的Regex

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.