假设有一段这样的文字对广东分舵是:-
翻开历史的肌肤:-
倒萨的阿斯顿:-
问题一:中间的空白部分使用replace替换不掉,导入byte[] 知道这部风的值是32
问题二:C#的正则表达式里有这样的功能吗?我新建一个string[],string[0]="对广东分舵是";string[1]="翻开历史的肌肤"
 string[2]="倒萨的阿斯顿" 我就是要这样的结果

解决方案 »

  1.   


                string str = @"对广东分舵是:-
    翻开历史的肌肤:-
    倒萨的阿斯顿:-";
                string[] result = str.Split(new char[] { '\r', '\n', '-' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string s in result)
                    Console.WriteLine(s);
      

  2.   

    结贴吧!只能自己在byte数组里把这些玩意弄掉吧!
      

  3.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                string str = @"对广东分舵是:-
    翻开历史的肌肤:-
    倒萨的阿斯顿:-";
                string[] result = str.Split(new char[] { '\r', '\n', '-' });
                foreach (string s in result)
                    Console.WriteLine(s);
            }       
           
        }
       
    }
      

  4.   

    6楼的高手帮我解决一下Excel导入数据库的问题呗!
      

  5.   

    谢谢你热心的回答!你这种我试了,你如果是在程序里写个这样的字符串这样分是没有问题的!
    我的是重HTML提取的类似的字符串!所以
    中间总是有段CONsle输出 看起来像是空白,但是就是用null replace掉~!
      

  6.   

            static void Main(string[] args)
            {
                string str = @"对广东分舵是:-
    翻开历史的肌肤:-
    倒萨的阿斯顿:-";
                Regex reg = new Regex(@"(?m)^\S+");
                MatchCollection mc = reg.Matches(str);
                foreach (Match m in mc)
                {
                    Console.WriteLine(m.Value);
                }        }