它应该工作得很好。
MongoDB shell version: 2.2.0
connecting to: test
> db.test.insert({text: "this is some sample text"})
> db.test.find()
{ "_id" : ObjectId("50d50b85499df584cc266f9a"), "text" : "this is some sample text" }
> db.test.find({text: /sample/})
{ "_id" : ObjectId("50d50b85499df584cc266f9a"), "text" : "this is some sample text" }
> db.test.find({text: /.*sample.*/})
{ "_id" : ObjectId("50d50b85499df584cc266f9a"), "text" : "this is some sample text" }
即使您的确切样本也有效:
> db.test.insert({text:"why does this not work"})
> db.test.find({"text":/.*why.*/})
{ "_id" : ObjectId("50d50c4c499df584cc266f9b"), "text" : "why does this not work" }
也许你忽略了别的东西?