how to do regex operation to field with index in order to use it mongo code example
Example 1: mongodb regex case insensitive
db.collection.find({name:{'$regex' : '^((?!string).)*$', '$options' : 'i'}})
Example 2: mongodb regex
{ <field>: { $regex: /pattern/, $options: '<options>' } }
{ <field>: { $regex: 'pattern', $options: '<options>' } }
{ <field>: { $regex: /pattern/<options> } }