In a MongoDB query, I'm trying to match records that have a string field that contains a search term at the beginning of any word in that string. The regex works correctly on regex101.com.
/\bCh/i
Matching values:
Chia seeds
i like to eat Chia seeds
i like to eat chia seeds
However when I try the same in a MongoDB query, I get no matching records.
{
"TenantNames" : /(\bSmith)/i
}
I also tried /(\bSmith.*)/
i and /(\bSmith.*\b)/i
but they both return no matching records as well. What am I missing?
I'm using the C# driver for building queries.