title: How to query mongodb with a regex in the projection?
body: <p>Does anyone know if there is a way to query MongoDB and have only certain fields returned by using a regex as part of the projection?</p>
  
  <p>For example:  Given a collection having arbitrary field names, how might I query the collection and only return field names matching the regex '^foo'.</p>
  
  <p>Possibly something like this?</p>
  
  <pre><code>db.mycollection.find({},{$regex:"^foo"})
  </code></pre>
  
  <p>Thanks.
  Brent.</p>