How to find all the results containing a given substring with spaces in mongoose
Your research is very useful I found my answer from your question and I just read Mongoose and MongoDb documentation and got answerhttps://docs.mongodb.com/manual/reference/operator/query/regex/#op._S_regex
Vehicle.find({ registrationNo: { "$regex": registrationNo, "$options": "ix" }}, function (err, vehicle) {}// { <field>: { $regex: /pattern/, $options: '<options>' } }
Just provided options (i) will ignore case and (x) will truncate spaces from pattern
Screenshot from MongoDb documentation: