Mega Code Archive

 
Categories / C# / Development Class
 

Gets an individual member of the collection

using System; using System.Text.RegularExpressions; public class Class1 {    public static void Main()    {          string sentence = "This is a test";       string pattern = @"\b[Tt]\w*\b";        MatchCollection matches = Regex.Matches(sentence, pattern);       for (int ctr=0; ctr < matches.Count; ctr++)       {          Console.WriteLine(matches[ctr].Value);          }       } }