使用正则表达式对字符串进行拆分

实现效果:

  

知识运用:

  Regex类的Split()方法:根据正则表达式模式对字符串进行拆分

    public static string[] Split(string input,string pattern)  //返回一个数组类型

      input:要拆分的字符串  pattern:所匹配的正则表达式模式

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            string[] result = System.Text.RegularExpressions.Regex.Split(textBox1.Text,"[0-9]");
                foreach(string str in result){
                    textBox2.Text += str;
                }
        }
原文地址:https://www.cnblogs.com/feiyucha/p/10045964.html