title: Extracting float number from string using javascript
body: <p>I have a string in javascript:</p>
  <pre><code>ECTS: 7.5 pts
  </code></pre>
  <p>From this string I need to extract <code>7.5</code> and parse it to a float value..</p>
  <p>I've tried searching, but none of the solutions I found did the trick. I've tried:</p>
  <pre><code>var regex = /^\d+\.\d{0,3}$/;
  var string = &quot;ECTS: 7.5 pts&quot;;
  var number = parseFloat(string.match(regex));
  console.log(&quot;number is: &quot; + number);
  </code></pre>
  <p>I've tried with a couple of different regular expressions, but none of them have done the trick.</p>
  <p>I've created this <a href="https://fiddle.jshell.net/v4mdkj9a/" rel="nofollow noreferrer">fiddle</a> to illustrate the problem.</p>
  <h1>EDIT1</h1>
  <p>I used to have this <code>/\d+/</code> as my regex, but that didn't include floating point numbers.</p>
  <h1>EDIT2</h1>
  <p>I ended up using this as my regex <code>/[+-]?\d+(\.\d+)?/g</code></p>
  <p>Updated <a href="https://fiddle.jshell.net/v4mdkj9a/10/" rel="nofollow noreferrer">fiddle</a></p>