例:1111110"13423"0110111111111110"2123"01111111111111110"2213"011111111110"2343"01111
0的位置随机.要返回的是2个0之间的子字符串

解决方案 »

  1.   

    string yourstr = "021303213210321321032132130";
    string[] fields = yourstr.Split("0".ToCharArray());
      

  2.   


                string strInput = "11111101342301101111111111102123011111111111111102213011111111110234301111";
                Match  m1 = Regex.Match(strInput,"(0)(\\w+)(0)");
      

  3.   

    string str="1111110"13423"0110111111111110"2123"01111111111111110"2213"011111111110"2343"01111";
    string[] Array =str.Split(new Char[] {'0'});
    {}括号里面可以写几个字符、、
    比如想截取123到123之间字符串,string[] Array =str.Split(new Char[] {'1','2','3'});
    输出 foreach(string str in Array)
      

  4.   

    Split会把开始的0前面的子串,最后的0后面的子串也取出来看下下面两种效果,哪种是楼主想要的吧
    string test = "1111110\"13423\"0110111111111110\"2123\"01111111111111110\"2213\"011111111110\"2343\"01111";
    Regex reg = new Regex(@"0([^0]+)0");
    MatchCollection mc = reg.Matches(test);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Groups[1].Value + "\n";
    }string test = "1111110\"13423\"0110111111111110\"2123\"01111111111111110\"2213\"011111111110\"2343\"01111";
    Regex reg = new Regex(@"(?<=0)([^0]+)(?=0)");
    MatchCollection mc = reg.Matches(test);
    foreach (Match m in mc)
    {
        richTextBox2.Text += m.Groups[1].Value + "\n";
    }
      

  5.   


      string s = "01111110\"13423\"0110111111111110\"2123\"01111111111111110\"2213\"011111111110\"2343\"01111";
                    string[] ss = s.Split(new string[] { "0\"", "\"0" }, StringSplitOptions.RemoveEmptyEntries);
                    string result = "";
                    if (s.IndexOf("0\"") == 0)
                    {
                        for (int i = 0; i < ss.Length - 1; i++)
                        {
                            if (i % 2 == 0)
                            {
                                result +=ss[i]+ ",";
                            }
                        }
                      
                    }
                    else
                    {
                        for (int i = 0; i < ss.Length - 1; i++)
                        {
                            if (i % 2 > 0)
                            {
                                result += ss[i] + ",";
                            }
                        }
                    }
                    if (result != "")
                    {
                        result=result.Trim(',');
                    }
                    Response.Write(result); //13423,2123,2213,2343
      

  6.   

    Program.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Data.SqlClient;
    using System.Data;
    using System.Diagnostics;namespace Temp
    {
        class Program
        {
            static string s = "097r097we097r000w9e7rt907we09r7er790";
           
            static void Main(string[] args)
            {
                string[] store = s.Split(new string[1] { "0" }, StringSplitOptions.None);
                
                /*这里看你如何取,
                 * 如果010220,切分之后字符串“1”和“22”都算的话就取整个store数组
                   如果010220,切分之后字符串“1”作为结果的话就取store数组的单数集合store[1],store[3],store[5]......  */            Console.ReadLine();
            }    }
    }