基于regexp拆分字符串

Ana*_*hah 5 c# regex arrays string split

我想在C#中分割一个看起来像的字符串

A B C D"

这样得到的数组就会有

数组[0] ="a"

数组[1] ="b"

数组[2] ="c:d"

我使用什么正则表达式来实现所需的结果.

非常感谢

And*_*ite 4

如果分隔符冒号被空格分隔,则可以使用 \s 来匹配空格:

string example = "a : b : \"c:d\"";
string[] splits = Regex.Split(example, @"\s:\s");
Run Code Online (Sandbox Code Playgroud)