Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8020417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:41:15+00:00 2026-06-04T21:41:15+00:00

So I was reading Kyle’s book and came across this example he has used

  • 0

So I was reading Kyle’s book and came across this example he has used for using regular expressions to match some text:

db.reviews.find({
    user_id: ObjectId("4c4b1476238d3b4dd5000001"),
    text: /best|worst/i
})

But it doesn’t have a sample document so I can’t imagine how a document is structured that he is using for this example. So can you please draw a quick document that the regular expression above works on it?
As far as I can tell it has a _id key of course and a text key, but what the values of that text key look like?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:41:17+00:00Added an answer on June 4, 2026 at 9:41 pm

    Imagine something like this, there is a user collection elsewhere, and this is a collection of all reviews every user ever wrote. When you want to get all reviews by a particular user, you query for all reviews which match that user’s id – that’s the user_id part. Now you decide you only want the reviews that have the word best or the word worst in it (regardless of capitalization). That’s the second part of the query.

    Assuming the three documents below all had matching user_id then first and third would match the text query but the middle one would not.

    {
       user_id: ObjectId(),
       text : "This was the worst one of my life!"
    }
    
    {
    
       user_id: ObjectId(),
       text : "Totally awesome, couldn't be better!"
    }
    
    {
       user_id: ObjectId(),
       text : "BEST EVAH!"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Reading the Scala by Example book and there is this example when Martin explains
Reading PHP & jQuery Cookbook right now and it gives this example for using
Reading through some code, I came across the use of !0 and !1 .
Reading over some example Objective C code just now. @property (nonatomic, strong) IBOutlet UILabel
Reading the design guidelines. I came across a little issue while trying to practice
Reading through wikipedia I came across the concept of Sprints in Agile development. From
Reading on another forum I've came across the world of CSS Frameworks. The one
Reading this post has left me wondering; are nightly builds ever better for a
Reading this list of Chrome match patterns: http://code.google.com/chrome/extensions/match_patterns.html How do I specify a match
reading the SCJP book, I've found something like this in the chapter 1 self-test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.