日期:2014-05-18  浏览次数:20701 次

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

------解决方案--------------------
C# code

        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));
        }

------解决方案--------------------
C# code
            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];