Text operators

πŸ“Œ $regex

To match fields with string values. You can also look for full text using $text

db.movieDetails.find({β€œawards.text”: {$regex: /^Won .*/}})

Description of regex

  • Slashes delimit the regular expression

  • The char ^ means start at the beginning of the field we are matching

  • Then match exactly the characters stated

  • The . means match any character

  • The * means match any number of times

Last updated