[SERVER-6500] Regex find with different counts Created: 18/Jul/12 Updated: 09/Jul/16 Resolved: 18/Jul/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | 2.1.2 |
| Fix Version/s: | None |
| Type: | Question | Priority: | Major - P3 |
| Reporter: | erhan | Assignee: | Randolph Tan |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
ubuntu server 12.04 lts with 2GB ram ( virtual pc on MacOS X with Parallels Desktop) |
||
| Participants: |
| Description |
|
Hello I was just testing how to perform SQL Like operations in MongoDB but I am quite confused about the results. > db.user.find({Email:{$regex : "aslan"}}).count() And I think there should be more explanation and example about regex on the page http://www.mongodb.org/display/DOCS/Advanced+Queries Thnx |
| Comments |
| Comment by Randolph Tan [ 18/Jul/12 ] | |
|
Needs more explanation of the regex syntax. So we either document them or should at the very least direct them to the documentation of the pcre regex syntax (this is the library the server code currently uses to do regex matching). | |
| Comment by Randolph Tan [ 18/Jul/12 ] | |
|
Hi, You don't need the $regex if you want to use the // notation. Ex:
^ is a marker used to indicate that strings will only count as a match if it the pattern is at the beginning of the string. Ex. of strings that will match /^aslan/: "aslander" Ex. of strings that will not match /^aslan/: "gaslander" |