-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 2.1.2
-
Component/s: Shell
-
None
-
Environment:ubuntu server 12.04 lts with 2GB ram ( virtual pc on MacOS X with Parallels Desktop)
Hello I was just testing how to perform SQL Like operations in MongoDB but I am quite confused about the results.
The usage of "/" char and "^" and also the results are strange.Is there something I am missing ?
Queries and results are below :
> db.user.find({Email:{$regex : "aslan"}}).count()
4174
> db.user.find({Email:{$regex : "^aslan"}}).count()
841
> db.user.find({Email:{$regex : "/^aslan/"}}).count()
0
> db.user.find({Email:{$regex : "/aslan/"}}).count()
0
> db.user.find({Email:{$regex : "aslan*"}}).count()
4410
> db.user.find({Email:{$regex : ".aslan."}}).count()
4174
> db.user.find({Email:{$regex : "/.aslan./"}}).count()
0
And I think there should be more explanation and example about regex on the page http://www.mongodb.org/display/DOCS/Advanced+Queries
Thnx