Splitting string based on uneven number of white spaces

前端 未结 2 1700
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 04:53

I need to split a string that looks like this

1052 root         0 SW<  [hwevent]

into the following

1052
root
0
SW<
[         


        
2条回答
  •  难免孤独
    2020-12-07 05:19

    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.

提交回复
热议问题