日期:2014-05-18 浏览次数:20746 次
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)); }
------解决方案--------------------
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];