string sentence = \"X10 cats, Y20 dogs, 40 fish and 1 programmer.\";
string[] digits = Regex.Split (sentence, @\"\\D+\");
for this code i get val
You'll need to allow for decimal places in your regular expression. Try the following:
\d+(\.\d+)?
This will match the numbers rather than everything other than the numbers, but it should be simple to iterate through the matches to build your array.
Something to keep in mind is whether you should also be looking for negative signs, commas, etc.