I’m trying to convert a string that contains multiple numbers, where each number is separated by white space, into a double array.
For example, the original string looks like:
originalString = "50 12.2 30 48.1"
I’ve been using Regex.Split(originalString, @”\s*”), but it’s returning an array that looks like:
[50 "" 12 "." 2 "" ...]
Any help is much appreciated.
The
Wherereturns anIEnumerablewith the null/whitespace filtered out. if you want it as an array still, then just add.ToArray()to that chain of calls.The
+character is necessary because you need a MINIMUM of one to make this a correct match.