Get MatchCollection : Regular Expression « Development Class « C# / C Sharp
- C# / C Sharp
- Development Class
- Regular Expression
Get MatchCollection
using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string input = "this is a test";
string pattern = "is?";
MatchCollection matches = Regex.Matches(input, pattern);
foreach (Match match in matches)
Console.WriteLine("'{0}' found in the source code at position {1}.",
match.Value, match.Index);
}
}
Related examples in the same category