using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"the";
string input = @"Here are some words: one, two, three, FOUR.
And here are some numbers: 1, 2, 3, 4, 10, 20, 30, 40, 100, 200, 300, 400, 1000.
Here are some mixed things: A1, A2, A3, A4
3 + 4 = 7
12 / 3 = 4
2 ^ 2 = 4
I think I've seen this film before
And I didn't like the ending
You're not my homeland anymore
So what am I defending now?
You were my town
Now I'm in exile, seein' you out
I think I've seen this film before
I can see you starin', honey
Like he's just your understudy
Like you'd get your knuckles bloody for me
Second, third, and hundredth chances
Balancin' on breaking branches
Those eyes add insult to injury";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx