title: Sum all kind of number resulting from regular expression
body: <p>I'm working on a function which sum's all numbers from a text:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>'use strict';
  
  var sum = function(text, regex) {
    var match;
    return !!(match = text.match(regex || /\d+/g)) ?
      match.reduce(function(prev, curr) {
        return +prev + +curr;
      })
    : 0;
  }
  
  console.log(sum('1 12 40'));
  console.log(sum('10 12 40'));
  console.log(sum('1 12 510'));
  console.log(sum('LLLLLLLL'));
  console.log(sum('10 1'));</code></pre>
  </div>
  </div>
  </p>
  
  <p>And is not working it numbers with points:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    'use strict';
  
      var sum = function(text, regex) {
        var match;
        return !!(match = text.match(regex || /\d+/g)) ?
          match.reduce(function(prev, curr) {
            return +prev + +curr;
          })
        : 0;
      }
  
      console.log(sum('1.10 12.40 40.30'));</code></pre>
  </div>
  </div>
  </p>
  
  <p>So, i would like to ask for help. How could i also sum numbers with pointers?</p>
  
  <p>Thanks.</p>