Info
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
Top User Comments
thomas.schubert commented on Tue, 25 Apr 2017 15:41:11 +0000:
Hi greenlaw110,
That's right, I've updated the ticket summary to clarify this behavior.
Kind regards,
Thomas
greenlaw110 commented on Tue, 25 Apr 2017 06:04:34 +0000:
Alright so according to http://stackoverflow.com/questions/43602310/mongdodb-regex-matching-failed-when-presented/43602744#43602744 it is due to partial matching, not a bug