您的位置:首页 > 其它

正则表达式替换字符串

2007-07-20 18:49 239 查看
正则表达式替换字符串

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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: