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

$regex not returning the correct documents when using a escaped dot

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

      When using : { email : { $regex : "bob\.lastname", $options : "i"}} it returns the document (which is ok)
      BUT when using : { email : { $regex : "b\.lastname", $options : "i"}} it also returns the document which should not happen. I expect only a match on "b.lastname"

      Show
      When using : { email : { $regex : "bob\.lastname", $options : "i"}} it returns the document (which is ok) BUT when using : { email : { $regex : "b\.lastname", $options : "i"}} it also returns the document which should not happen. I expect only a match on "b.lastname"

      I have a document where i store a email adres, on insert of a new document i want to check if the email adres is already in use.

      See the document below with a simple (yes i know not ok) email, i just want 1 dot to simplify

      { "_id" : ObjectId("5911b0ce055cdb7a64d79892"), "first_name" : "Bob", "last_name" : "Lastnam", "email" : "bob.lastname" }

      I use a $regex to search if there are already documents present with the email. i escape the "special" dot so it's handled like a literal.

            Assignee:
            Unassigned Unassigned
            Reporter:
            dennis@hoefakkr.nl Dennis Hoefakker
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: