Articles → MONGODB → $Regex Operator In Mongodb

$Regex Operator In Mongodb






Purpose





Syntax


db.collection.find({ "field": { $regex: /pattern/ } })



Example




db.Articles.find({subject:{$regex:/Mongo/}})


Picture showing the list of documents having the word Mongo




db.Articles.find({subject:{$regex:/^Mongo/}})


Picture showing the list of documents that starts with the word mongo





Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, March 5, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250