I need to split a string that looks like this
1052 root 0 SW< [hwevent]
into the following
1052
root
0
SW<
[
You may use StringSplitOptions.RemoveEmptryEntries
string strtemp = "1052 root 0 SW< [hwevent]";
string[] array = strtemp.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
Yes, regex:
splitArray = Regex.Split(subjectString, @"\s+");
Explanation:
\s+
matches one or more whitespace characters at once, so it splits on any (positive) number of whitespace characters.