求一拆分字串的算法
我有一字串需要拆分,如下:
"a"&"b"&"c"||"d" 或
"a" & "b" & "c" || "d"
希望可以拆分为四个子字串:
a
b
c
d
算法
------解决方案-------------------- string content = "\"a\" & \"b\" & \"c\"
------解决方案--------------------
\"d\"";
var txt = Regex.Matches(content, "[a-zA-Z]").OfType<Match>().Select(x => x.Groups[0]);
------解决方案--------------------string ss = @"""a"" & ""b"" & ""c""
------解决方案-------------------- ""d""";
string[] arraystr = ss.Split(new string[] { "&", "
------解决方案--------------------" }, StringSplitOptions.RemoveEmptyEntries);
arraystr.Where(x => !String.IsNullOrEmpty(x)).ToList().ForEach(x => Console.WriteLine(x));