正则表达式替换字符串

string pattern = @"CREATE\s+PROC(EDURE)?";
            Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);

            string inputStr = "CREATe  PROC spTest";

            // Replace runs of white space in the input string with a
            // comma and a blank.
            string outputStr = rgx.Replace(inputStr, "ALTER PROCEDURE");

            // Display the resulting string.
            Console.WriteLine("Pattern:       \"{0}\"", pattern);
            Console.WriteLine("Input string:  \"{0}\"", inputStr);
            Console.WriteLine("Output string: \"{0}\"", outputStr);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2022-12-23
相关资源
相似解决方案