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

Regex find with different counts

    XMLWordPrintableJSON

Details

    • Icon: Question Question
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • 2.1.2
    • Shell
    • None
    • ubuntu server 12.04 lts with 2GB ram ( virtual pc on MacOS X with Parallels Desktop)

    Description

      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

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: