正则表达式替换字符串

正则表达式替换字符串

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

你可能感兴趣的:(正则表达式)