title: Get substrings from field in MongoDB
body: <p>I have collection with information about applications. Each document have field <strong>ver</strong> which holds version of application. Examples:</p>
  
  <pre><code>"1.0.0.2" (they are strings)
  "2.0.3.10"
  "3.1.5.111"
  </code></pre>
  
  <p>First 3 digints is <em>major</em> version, and last number is <em>build</em> version. I wander, is there any way I can get group by <em>major</em> version of application?</p>
  
  <p><strong>Example</strong></p>
  
  <p>Input collection:</p>
  
  <pre><code>{_id: ..., ver: "1.0.0.1"}, 
  {_id: ..., ver: "1.0.0.2"}, 
  {_id: ..., ver: "2.2.3.0"}
  </code></pre>
  
  <p>Aggregation result:</p>
  
  <pre><code>[ 
   {ver:"1.0.0", count:2},
   {ver:"2.2.3", count:1}
  ]
  </code></pre>
  
  <p>P.S. I'd prefer solution with Aggregation Framework :)</p>