当前位置:K88软件开发文章中心编程语言.NET.NET02 → 文章内容

C# 正则表达式

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-14 1:48:22

Console.ReadKey(); } }}当上面的代码被编译和执行时,它会产生下列结果:Matching words start with 'm' and ends with 'e':The Expression: \bm\S*e\bmakemazemanagemeasure实例 3下面的实例替换掉多余的空格:using System;using System.Text.RegularExpressions;namespace RegExApplication{ class Program { static void Main(string[] args) { string input = "Hello World "; string pattern = "\\s+"; string replacement = " "; Regex rgx = new Regex(pattern); string result = rgx.Replace(input, replacement); Console.WriteLine("Original String: {0}", input); Console.WriteLine("Replacement String: {0}", result); Console.ReadKey(); } }}当上面的代码被编译和执行时,它会产生下列结果:Original String: Hello World Replacement String: Hello World

上一页  [1] [2] [3] 


C# 正则表达式