1

I am looking for a string in mongo that does not discriminate between lower and upper case, the problem is that if a record has a "+" sign it does not find it.

{ username: { $regex: "ExamPle+33@gmail.com", $options: "i" } } // does not work


{ username: { $regex: "ExamPle33@gmail.com", $options: "i" } } // works
tanjiro
  • 81
  • 6

1 Answers1

1

You must escape the character "+".

Try something like this:

variable = "^ExamPle\\+33@gmail.com$"
db.testcollection.find({ username: { $regex: variable, $options: "i" } })

Look at the following link Case insensitive search in Mongo

kevic
  • 449
  • 4
  • 6