- usingSystem;
- usingSystem.Text.RegularExpressions;
- publicclassExample
- {
- staticvoidMain()
- try
- stringinput="Thisistextwithfartoomuch"+"whitespace.";
- stringpattern="\\s+";
- stringreplacement="";
- Regexrgx=newRegex(pattern);
- stringresult=rgx.Replace(input,replacement);
- Console.WriteLine("OriginalString:{0}",input);
- "ReplacementString:{0}",result);
- Console.Read();
- }
- catch(Exception)
- {
- throw;
- }
- }