0

I am searching record with full matching string difference is only a small letter in the string. But the string having ().

"name" : {
    "en" : "Monginis Chocolate Muffins 6 N (150 g Each)",
    "hi" : "",
    "te" : ""
}

Query

db.shop_items.findOne({'name.en':{$regex:'.*\Monginis Chocolate Muffins 6 N (150 g Each).*',$options:'i'}})
  • Read the links. Not only does escaping regular expressions have an existing answer here, but with a modern MongoDB you should be able to search case insensitive without even using a regex when you know the exact string which only differs in case. Examples and documentation links are there. – Neil Lunn May 02 '18 at 10:42
  • I am not escaping the (), I am directely searching the text but string having the () so record is not coming. Parenthesis are included in the string. It is like a where condition but because of case-senstive I am using regex – Ajay Malik May 02 '18 at 11:00
  • You got linked there because parenthesis `()` are **special regex characters**. You "must" escape them – Neil Lunn May 02 '18 at 11:04

0 Answers0