Mega Code Archive

 
Categories / C# Tutorial / Regular Expression
 

S Match a white-space character

using System; using System.Text.RegularExpressions; public class Example {    public static void Main()    {       string pattern = @"gr[ae]y\s\S+?[\s|\p{P}]";       string input = "this is a test.";       MatchCollection matches = Regex.Matches(input, pattern);       foreach (Match match in matches)          Console.WriteLine(match.Value);    } }