Mega Code Archive

 
Categories / C# / Development Class
 

Match Class represents the results from a single regular expression match

using System; using System.Text.RegularExpressions; public class Example {    public static void Main()    {         string pattern = "dog";         string input = "this is a dog.";         Match match = Regex.Match(input, pattern);         if (match.Success )            Console.WriteLine("'{0}' was found at position {1} in '{2}'.",match.Value, match.Index + 1, input);         else            Console.WriteLine("The pattern '{0}' was not found in '{1}'.",pattern, input);             } }