正则表达式替换字符串

正则表达式替换字符串

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 突破自己 阅读(177) 评论(0)  编辑 收藏

标题  
姓名  
主页
Email (博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-07-21 10:28 编辑过


相关链接: