请教一个问题,一个字符串,数字后的第一个字母大写
不要ToCharArray()  这种方法

解决方案 »

  1.   


            private string CapText(Match m)
            {
                return m.Value.ToUpper();
            }        private void button10_Click(object sender, EventArgs e)
            {
                string source = "123abc56bde78mfg";
                Regex reg = new Regex(@"(?is)(?<=\d)[a-z]");
                source = reg.Replace(source, new MatchEvaluator(CapText));
            }结果
    source = "123Abc56Bde78Mfg"
      

  2.   

    崇拜4楼啊   努力ing.....
      

  3.   

                StringBuilder a = new StringBuilder("123abc56bde78mfg");
                for (int i = 1; i < a.Length; ++i)
                    a[i] = char.IsLower(a[i]) ? (char.IsDigit(a[i-1]) ? char.ToUpper(a[i]) : a[i]) : a[i];a.ToString() = 123Abc56Bde78Mfg