[SERVER-29117] $regex not returning the correct documents when using a escaped dot Created: 09/May/17  Updated: 03/Apr/23  Resolved: 10/May/17

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 3.5.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Dennis Hoefakker Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

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"

Participants:

 Description   

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.



 Comments   
Comment by Kelsey Schubert [ 10/May/17 ]

Hi HoefMeistert,

Thanks for the update; I'm closing this ticket per your request. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this would be best posted on the mongodb-users group.

Kind regards,
Thomas

Comment by Dennis Hoefakker [ 10/May/17 ]

Please close this issue, i think it was late :S... Totally forgot to add the ^ and $... b\.lastname is correct, cause it matches --b.lastname :S Sorry for the inconvenience

Generated at Thu Feb 08 04:19:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.