花边管理软件官方网站

正则表达式替换字符串

正则表达式替换字符串

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

posted @ 2007-07-20 18:49  花边软件,花边管理软件,服装(鞋)管理软件  Views(506)  Comments(0Edit  收藏  举报
花边管理软件官方网站