在TextBox中,有两个字段              000001: IBM
            000002: 微软我用用什么方法才能把000001和000002读取出来呢?

解决方案 »

  1.   

    Regex.Match(textBox1.Text, @"(?s)000001:\s*(.*?)\s*000002:\s*(.*?)\s*")
      

  2.   


    bool GetMyString(string textBox1String,out string str1,out string str2){
    string.indexof()
    string.substring()
    string.split()
    }
    ........
    这么多函数呢,怎么还读不出来.
      

  3.   

    string textboxtext = this.textbox.text;
    string[] text = textboxtext.Split('\n');
    for(int i=0;i<text.length;i++)
    {
    Regex.Match(textBox1.Text, @"\d+")
    }
    如果每段开头都是数字的话.而且段落是规则的话
      

  4.   

    using System;
    using System.Text.RegularExpressions;class Test
    {
      static void Main()
      {
        string s    = @"
    000001:   IBM 
                            000002:   微软
    ";                        
        MatchCollection ms = Regex.Matches(s, @"\d:\s*(.*?)\r\n");
        foreach (Match m in ms)
        {
          string t = m.Groups[1].Value;  // 这就是你要的
          Console.WriteLine(t);
        }
      }
    }