using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(\w+)-(\w+)-(\w+)-(\d)$";
string input = @"aaa-bbb-bbb-ccc-1
aaa-bbbbbb-cccc-1
a-bbbbbb-cccc-1
a-b-cccc-1
a-b-c-1
a-b-c
aaa_1-bbb_2-bbb_3-ccc_4-1
aaa_1-bbbbbb_2-cccc_3-1
a_1-bbbbbb_2-cccc_3-1
a_1-b_2-cccc_3-1
a_1-b_2-c_3-1
a_1-b_2-c_3";
RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | 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