利用 Regex.Replace 方法,把一段字符串中的小写字母转换成大写,该程序仅仅是为了演示 Regex.Replace 的重载方法:

using System;
using System.Text.RegularExpressions;

namespace ConAppTempTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Regex r = new Regex("[a-zA-Z]+");
            string str = "sdf中国人e";
            string strResult = r.Replace(str, delegate(Match m){return m.Value.ToUpper();});
            //或者
            //string strResult = r.Replace(str, m => m.Value.ToUpper());
            //或者
            //string strResult = str.ToUpper();
            Console.WriteLine(strResult);
            Console.ReadKey();
        }
    }
}

谢谢浏览!

相关文章:

  • 2022-02-04
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-13
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2021-10-07
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案