[C#] 多分隔符文本分割
1 string s = "1,\r\n2,\r\n3,\r\n"; 2 s.Replace(",", "").Replace("\r", "").Split('\n').ToList(); //结果 : [1,2,3,""] 3 s.Split(new string[] { ",", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); //结果 : [1,2,3]
1 string s = "1,\r\n2,\r\n3,\r\n"; 2 s.Replace(",", "").Replace("\r", "").Split('\n').ToList(); //结果 : [1,2,3,""] 3 s.Split(new string[] { ",", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); //结果 : [1,2,3]