I am using a case insensitive search in Mongo, something similar to https://stackoverflow.com/q/5500823/1028488.
ie. I am using a regex with options i. But I am having trouble restricting the regex to just that word, it performs more like a ‘Like’ in SQL
eg: if I use query like
{"SearchWord" : { '$regex' : 'win', $options: '-i' }}, it shows me results for win, window & winter. How do i restrict it to jsut show win?
I tried /^win$/ but it’s saying invalid JSON… Please suggest away.
You can use
'$regex':'^win$'or/^win$/i(notice no quote on the second one)Source here : Regex in queries with Mongo