title: How to extract decimal number from string in C#
body: <pre class="lang-cs prettyprint-override"><code>string sentence = &quot;X10 cats, Y20 dogs, 40 fish and 1 programmer.&quot;;
  string[] digits = Regex.Split (sentence, @&quot;\D+&quot;);
  </code></pre>
  <p>For this code I get these values in the digits array</p>
  <blockquote>
  <p>10,20,40,1</p>
  </blockquote>
  <pre class="lang-cs prettyprint-override"><code>string sentence = &quot;X10.4 cats, Y20.5 dogs, 40 fish and 1 programmer.&quot;;
  string[] digits = Regex.Split (sentence, @&quot;\D+&quot;);
  </code></pre>
  <p>For this code I get these values in the digits array</p>
  <blockquote>
  <p>10,4,20,5,40,1</p>
  </blockquote>
  <p>But I would like to get like</p>
  <blockquote>
  <p>10.4,20.5,40,1
  as decimal numbers. How can I achieve this?</p>
  </blockquote>