我有一字串需要拆分,如下:
"a"&"b"&"c"||"d" 或
"a" & "b" &   "c"  ||   "d"希望可以拆分为四个子字串:
a
b
c
d算法

解决方案 »

  1.   

      string content = "\"a\" & \"b\" &   \"c\"  ||   \"d\"";
                var txt = Regex.Matches(content, "[a-zA-Z]").OfType<Match>().Select(x => x.Groups[0]);
      

  2.   

    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));
      

  3.   

    多谢两位楼主的回复
    如果是下面的字串:
    "a & "b" & "c"||"d"
    我想做到拆分出来的字串为:
    a&"b
    c
    d也就是以& 和 ||来拆分字串,前且字串都必需是包含在双引号中的