正则表达式替换字符串
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);
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);
相关文章推荐
- Oracle正则表达式替换字符串
- 正则表达式的一个应用(替换字符串)
- 利用正则表达式 替换字符串中多个 URL
- PHP使用正则表达式查找替换字符串
- C# 利用正则表达式进行忽略大小写的字符串替换的应用--自定义高亮显示
- Java_正则表达式_按给定正则表达式分割或替换字符串
- JavaScript利用正则表达式替换字符串中的内容
- Python正则表达式如何进行字符串替换
- sed替换字符串时,使用正则表达式的注意事项
- SQL Server中利用正则表达式替换日期中的"-|:| "字符串为空
- JS使用replace()方法和正则表达式进行字符串的搜索与替换实例
- js正则表达式,实现字符串替换
- javaScript正则表达式提取字符串中字母、数字、中文 && 字符串替换
- python正则表达式使用实例-替换字符串HTML标签
- [Javascript]用正则表达式替换字符串中的图片地址(img src)
- java中的正则表达式 字符串的拆分,匹配,替换
- 特殊字符导致用正则表达式进行字符串替换失败,Java replaceAll()方法报错Illegal group reference
- EditPlus正则表达式替换字符串
- Linux C 支持正则表达式的字符串替换函数
- 【转】在EditPlus中利用正则表达式替换字符串