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

Regex returns partial matches

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • ALL
    • Hide

      See description

      Show
      See description

      Original Summary

      Regex matching failed when ":" is presented

      Original Description

      Here is my mongodb shell session

      > db.foo.save({path: 'a:b'})
      WriteResult({ "nInserted" : 1 })
      > db.foo.findOne()
      { "_id" : ObjectId("58fedc47622e89329d123ee8"), "path" : "a:b" }
      > db.foo.save({path: 'a:b:c'})
      WriteResult({ "nInserted" : 1 })
      > db.foo.find({path: /a:[^:]+/})
      { "_id" : ObjectId("58fedc47622e89329d123ee8"), "path" : "a:b" }
      { "_id" : ObjectId("58fedc57622e89329d123ee9"), "path" : "a:b:c" }
      > db.foo.find({path: /a:[a-z]+/})
      { "_id" : ObjectId("58fedc47622e89329d123ee8"), "path" : "a:b" }
      { "_id" : ObjectId("58fedc57622e89329d123ee9"), "path" : "a:b:c" }
      

      Clearly the regex /a:[^:]/ and /a:[a-z]/ shall not match string 'a:b:c', but looks like mongo failed on this regex

            Assignee:
            Unassigned Unassigned
            Reporter:
            greenlaw110 Green Luo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: