using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(n|an_nh)_(vc_v|naca_(i|E[1-4]|k_[1-4][1-4]))";
string input = @"Should match:
an_nh_naca_i
an_nh_naca_k_12
an_nh_naca_k_21
an_nh_naca_k_23
an_nh_naca_k_32
an_nh_naca_k_34
an_nh_naca_k_43
an_nh_naca_k_41
an_nh_naca_k_14
an_nh_naca_E1
an_nh_naca_E2
an_nh_naca_E3
an_nh_naca_E4
an_nh_vc_v
n_naca_i
n_naca_k_12
n_naca_k_21
n_naca_k_23
n_naca_k_32
n_naca_k_34
n_naca_k_43
n_naca_k_41
n_naca_k_14
n_naca_E1
n_naca_E2
n_naca_E3
n_naca_E4
n_vc_v
Should not match:
an_nh_naca_F1_3n_i
an_nh_naca_F1_3n_o
n_naca_F1_3n_i
n_naca_F1_3n_o";
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