19
1
using System;
2
using System.Text.RegularExpressions;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
string regexPattern = @"hello";
9
Regex regex = new Regex(regexPattern);
10
string inputString = "hello world! hello again!";
11
12
MatchCollection matches = regex.Matches(inputString);
13
14
foreach (Match match in matches)
15
{
16
Console.WriteLine("Match found at index {0} with length {1}", match.Index, match.Length);
17
}
18
}
19
}
Cached Result
Enter a number :
>