Split string into comma and space at the same time

I have a string that contains commaand space. I need to split this string based on these two and add it to the string array. Until now, I have done this both comma and space, but not at the same time. Here is the line:

2013/02/05 11: 50: 57.00: 00: 17.5.9870, O, 9851.9851, 1.1029441.0, E9870, Extn9870, E9851, GM PS, 0.0 ,,,,, ,,

As you can see from the above line example 2013/02/05 11:50:57, it contains a space and a remainder, each of which is separated by a comma.

Here is the code I tried.

 string[] str = line.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
+7
source share
2 answers

Just add a space to the delimiter array?

string[] str = line.Split(new[] { ',', ' ' }, 
                                StringSplitOptions.RemoveEmptyEntries);
+16
source

, , - :

string[] str = line.Replace(" ", ",").Split(',');
-1

All Articles