更新时间:2023-11-05 09:10:46
String.Split
允许使用多个拆分直径.我不知道这是否适合您的问题.
String.Split
allows multiple split-delimeters. I don't know if that fits your question though.
示例:
String text = "Test;Test1:Test2#Test3";
var split = text.Split(';', ':', '#');
//split contains an array of "Test", "Test1", "Test2", "Test3"
您可以使用正则表达式保留分号.
you can use a regex to keep the delimeters.
String text = "Test;Test1:Test2#Test3";
var split = Regex.Split(text, @"(?<=[;:#])");
// contains "Test;", "Test1:", "Test2#","Test3"