Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-6500

Regex find with different counts

    • Type: Icon: Question Question
    • Resolution: Done
    • Priority: Icon: Major - P3 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

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            e2burner erhan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: