C#-String字符串操作

贴代码。这些都是方法,不懂的留言

        private void StSplit()
        { 
            //检查所有字符串符号相同去掉
            Char[] delimiChars = { ' ', ',', '.', ':', '	' };
            string text = "one	two three:four,five six seven";
            tbText.Text = text;
            string[] words = text.Split(delimiChars);
            foreach (string s in words)
            {
                //数组遍历 组合
                st2 = st2 + s;
                log.Info("s===" + s);
                log.Info("st2==" + st2);
            }
            tbtext2.Text = st2;
            // 输出格式:onetwothreefourfivesixseven

        }


        public void St_Replace()
        {
            st = "123 123456 85797 
abc def adcc abaaa";
            tbText.Text = st;
            //替换字符 全部替换
            String st2 = st.Replace("123", "333");
            tbtext2.Text = st2;
            /* 
             * *输出格式:333 333456 85797 
                          abc def adcc abaaa
             * * */
        }
原文地址:https://www.cnblogs.com/hs22/p/6896872.html