title: mongo:how to query by regex in mongo
body: <p>I am meeting a problem,just as follows:</p>
  
  <pre><code> {"_id":ObjectId("XXXXXXXX"),"phone":"123456"}
  </code></pre>
  
  <p>and now i want to query the document that the length of phone field is 5. I run the command as follows,</p>
  
  <pre><code>db.Phone.find({"phone":{"$regex":"\d{5}"}})
  </code></pre>
  
  <p><strong>or</strong></p>
  
  <pre><code>db.Phone.find({"phone":/\d{5}/})
  </code></pre>
  
  <p>they all do not Work. Could anybody help me figure out, how to use regex in mongo?</p>